Class: SimpleTables::Record
- Inherits:
-
Object
- Object
- SimpleTables::Record
- Defined in:
- lib/simple_tables/table.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(values, col_names) ⇒ Record
constructor
A new instance of Record.
- #matches?(conditions) ⇒ Boolean
Constructor Details
#initialize(values, col_names) ⇒ Record
Returns a new instance of Record.
25 26 27 |
# File 'lib/simple_tables/table.rb', line 25 def initialize(values,col_names) @data=Hash[col_names.zip(values)] end |
Instance Method Details
#[](key) ⇒ Object
29 30 31 |
# File 'lib/simple_tables/table.rb', line 29 def [](key) @data[key] end |
#matches?(conditions) ⇒ Boolean
33 34 35 |
# File 'lib/simple_tables/table.rb', line 33 def matches?(conditions) conditions.all? { |k,v| self[k] == v } end |