Class: BAMFCSV::Table::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fieldsObject (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

#headersObject



50
51
52
# File 'lib/bamfcsv/table.rb', line 50

def headers
  @header_map.keys
end

#inspectObject



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