Class: Topographer::Importer::Input::Roo
- Inherits:
-
Base
- Object
- Base
- Topographer::Importer::Input::Roo
show all
- Includes:
- Enumerable
- Defined in:
- lib/topographer/importer/input/roo.rb
Instance Method Summary
collapse
Methods inherited from Base
#failure_message, #importable?
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, =1, data_row=2)
@sheet = roo_sheet
@header = @sheet.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
|
11
12
13
|
# File 'lib/topographer/importer/input/roo.rb', line 11
def
@header
end
|
15
16
17
18
|
# File 'lib/topographer/importer/input/roo.rb', line 15
def input_identifier
@sheet.default_sheet
end
|