Class: Topographer::Importer::Input::Roo
- Includes:
- Enumerable
- Defined in:
- lib/topographer/importer/input/roo.rb
Instance Method Summary collapse
- #each ⇒ Object
- #get_header ⇒ Object
-
#initialize(roo_sheet, header_row = 1, data_row = 2) ⇒ Roo
constructor
A new instance of Roo.
- #input_identifier ⇒ Object
Constructor Details
#initialize(roo_sheet, header_row = 1, data_row = 2) ⇒ Roo
Returns a new instance of Roo.
4 5 6 7 8 9 |
# File 'lib/topographer/importer/input/roo.rb', line 4 def initialize(roo_sheet, header_row=1, data_row=2) @sheet = roo_sheet @header = @sheet.row(header_row).map(&:strip) @start_data_row = data_row @end_data_row = @sheet.last_row end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/topographer/importer/input/roo.rb', line 20 def each @start_data_row.upto @end_data_row do |row_number| data = @sheet.row(row_number) source_identifier = "Row: #{row_number}" if data.reject{ |column| column.blank? }.any? yield Topographer::Importer::Input::SourceData.new( source_identifier, Hash[@header.zip(data)] ) end end end |
#get_header ⇒ Object
11 12 13 |
# File 'lib/topographer/importer/input/roo.rb', line 11 def get_header @header end |
#input_identifier ⇒ Object
15 16 17 18 |
# File 'lib/topographer/importer/input/roo.rb', line 15 def input_identifier #This is apparently how you get the name of the sheet...this makes me sad @sheet.default_sheet end |