Class: Spread2RDF::RooAdapter
- Inherits:
-
Object
- Object
- Spread2RDF::RooAdapter
- Includes:
- Singleton
- Defined in:
- lib/spread2rdf/roo_helper.rb
Instance Method Summary collapse
- #cell(coord, worksheet = nil) ⇒ Object
-
#initialize ⇒ RooAdapter
constructor
A new instance of RooAdapter.
-
#load(file) ⇒ Object
TODO: make this work with other spreadsheets than Excel.
- #roo(worksheet = nil) ⇒ Object
- #select_worksheet(worksheet) ⇒ Object
Constructor Details
#initialize ⇒ RooAdapter
Returns a new instance of RooAdapter.
6 7 8 |
# File 'lib/spread2rdf/roo_helper.rb', line 6 def initialize end |
Instance Method Details
#cell(coord, worksheet = nil) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/spread2rdf/roo_helper.rb', line 32 def cell(coord, worksheet = nil) coord = Coord[coord] unless coord.is_a? Coord #if worksheet @roo.cell(coord.column, coord.row, worksheet) #else # @roo.cell(coord.column, coord.row) #end end |
#load(file) ⇒ Object
TODO: make this work with other spreadsheets than Excel
11 12 13 14 15 16 |
# File 'lib/spread2rdf/roo_helper.rb', line 11 def load(file) = {} [:packed], [:file_warning] = :zip, :ignore if File.extname(file).downcase == '.xlsm' @roo = Roo::Excelx.new(file, ) end |
#roo(worksheet = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/spread2rdf/roo_helper.rb', line 22 def roo(worksheet = nil) return @roo if worksheet.nil? last_default_sheet = @roo.default_sheet select_worksheet(worksheet) return @roo unless block_given? result = yield @roo @roo.default_sheet = last_default_sheet result end |
#select_worksheet(worksheet) ⇒ Object
18 19 20 |
# File 'lib/spread2rdf/roo_helper.rb', line 18 def select_worksheet(worksheet) @roo.default_sheet = worksheet end |