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.
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 154 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
172 173 174 175 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 172 def rows_for(name) sheet = @roo.sheet(name) (1..sheet.last_row.to_i).map { |i| sheet.row(i) } end |
#sheet_names ⇒ Object
168 169 170 |
# File 'lib/opencdd/parcel/workbook_reader.rb', line 168 def sheet_names @sheet_names ||= @roo.sheets end |