Class: Opencdd::Parcel::WorkbookReader::RooSource
- Inherits:
-
Struct
- Object
- Struct
- Opencdd::Parcel::WorkbookReader::RooSource
- Defined in:
- lib/opencdd/parcel/workbook_reader.rb
Instance Method Summary collapse
-
#initialize(path, ext) ⇒ RooSource
constructor
A new instance of RooSource.
- #rows_for(name) ⇒ Object
- #sheet_names ⇒ Object
Constructor Details
#initialize(path, ext) ⇒ RooSource
Returns a new instance of RooSource.
150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 150 def initialize(path, ext) require "roo" roo_ext = case ext when ".xlsx" then :xlsx when ".xlsm" then :xlsm when ".xls" then :xls when ".csv" then :csv else :xlsx end super(path, roo_ext) @roo = Roo::Spreadsheet.open(path, extension: extension) end |
Instance Method Details
#rows_for(name) ⇒ Object
168 169 170 171 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 168 def rows_for(name) sheet = @roo.sheet(name) (1..sheet.last_row.to_i).map { |i| sheet.row(i) } end |
#sheet_names ⇒ Object
164 165 166 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 164 def sheet_names @sheet_names ||= @roo.sheets end |