Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
CSV::Row#field?
row.field?(value) → true or false
lib/csv/row.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/csv/row.rb, line 589
def field?(data)
fields.include? data
end
Returns true if value is a field in this row, false otherwise:
Example
source = "Name,Name,Name\nFoo,Bar,Baz\n" table = CSV.parse(source, headers: true) row = table[0] row.field?('Bar') # => true row.field?('BAR') # => false