Class: BAMFCSV::Table::Row
- Inherits:
-
Object
- Object
- BAMFCSV::Table::Row
- Defined in:
- lib/bamfcsv/table.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #headers ⇒ Object
-
#initialize(header_map, fields) ⇒ Row
constructor
A new instance of Row.
- #inspect ⇒ Object
Constructor Details
#initialize(header_map, fields) ⇒ Row
Returns a new instance of Row.
45 46 47 48 |
# File 'lib/bamfcsv/table.rb', line 45 def initialize(header_map, fields) @header_map = header_map @fields = fields end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
43 44 45 |
# File 'lib/bamfcsv/table.rb', line 43 def fields @fields end |
Instance Method Details
#[](key) ⇒ Object
54 55 56 |
# File 'lib/bamfcsv/table.rb', line 54 def [](key) @fields[@header_map[key]] end |
#headers ⇒ Object
50 51 52 |
# File 'lib/bamfcsv/table.rb', line 50 def headers @header_map.keys end |
#inspect ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/bamfcsv/table.rb', line 58 def inspect pairs = [] headers.each do |h| pairs << "#{h.inspect} => #{self[h].inspect}" end "{#{pairs.join(", ")}}" end |