Class: SimpleTables::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_tables/table.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


33
34
35
# File 'lib/simple_tables/table.rb', line 33

def matches?(conditions)
  conditions.all? { |k,v| self[k] == v }
end