Class: Cards::TabularParser::Row
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(header, row) ⇒ Row
constructor
A new instance of Row.
- #to_h ⇒ Object
Constructor Details
#initialize(header, row) ⇒ Row
Returns a new instance of Row.
59 60 61 |
# File 'lib/cards/tabular_parser.rb', line 59 def initialize(header, row) @header, @row = header, row end |
Instance Method Details
#[](key) ⇒ Object
63 64 65 66 |
# File 'lib/cards/tabular_parser.rb', line 63 def [](key) index = @header[key] || raise("can't find column header #{key.inspect} in #{@header.inspect}") @row[index] end |
#to_h ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/cards/tabular_parser.rb', line 68 def to_h h = {} @header.each_key do |column_header| val = @row[@header[column_header]] h[column_header] = val unless val.blank? end h end |