Class: CsvRecord::Condition
- Defined in:
- lib/csv_record/csv_queries/condition.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(field, value) ⇒ Condition
constructor
A new instance of Condition.
- #to_code ⇒ Object
Constructor Details
#initialize(field, value) ⇒ Condition
Returns a new instance of Condition.
4 5 6 7 |
# File 'lib/csv_record/csv_queries/condition.rb', line 4 def initialize(field, value) @field = field @value = value end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
2 3 4 |
# File 'lib/csv_record/csv_queries/condition.rb', line 2 def field @field end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
2 3 4 |
# File 'lib/csv_record/csv_queries/condition.rb', line 2 def value @value end |
Class Method Details
.create_from_hashes(hashes) ⇒ Object
9 10 11 12 13 |
# File 'lib/csv_record/csv_queries/condition.rb', line 9 def self.create_from_hashes(hashes) hashes.map do |hash| new *hash end end |
Instance Method Details
#to_code ⇒ Object
15 16 17 |
# File 'lib/csv_record/csv_queries/condition.rb', line 15 def to_code "attributes['#{@field}'] == '#{@value}'" end |