Sha256: 0869dfad471f51e9b1db8b9a9319541fc4940c05312e6f90a79f76bb98ad5a09
Contents?: true
Size: 623 Bytes
Versions: 1
Compression:
Stored size: 623 Bytes
Contents
require_relative '../spreadsheet' module FlexData class Spreadsheet def map_to_h (first = 1, last = -1) (first..last).inject([]) { |acc, index| acc << row_to_h(index) } end def map_to_ostruct (first = 1, last = -1) (first..last).inject([]) { |acc, index| acc << row_to_ostruct(index) } end def row_to_h (index) keys = @sheet[0] output = {} @sheet[index].each_with_index { |value, i| output.store(keys[i], value) } output end def row_to_ostruct (index) OpenStruct.new(row_to_h(index)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flex_data-0.1.3 | lib/flex_data/spreadsheet/open_struct.rb |