Class: Cloudsheet::Row

Inherits:
Hash
  • Object
show all
Defined in:
lib/cloudsheet/row.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ Row

Returns a new instance of Row.



3
4
5
# File 'lib/cloudsheet/row.rb', line 3

def initialize(map)
  @map = map
end

Class Method Details

.parse(data, map = nil) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/cloudsheet/row.rb', line 7

def self.parse(data, map = nil)
  map = Cloudsheet::Map.new unless map  
  row = self.new(map)
  data.each_with_index do |d, i|
    row[map[i].name] = map.read(i, d)
  end
  row
end