Class: Spread2RDF::Mapping::Spreadsheet
- Defined in:
- lib/spread2rdf/mapping/spreadsheet.rb
Instance Attribute Summary collapse
-
#input_file ⇒ Object
readonly
Returns the value of attribute input_file.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(schema, filename) ⇒ Spreadsheet
constructor
A new instance of Spreadsheet.
- #map ⇒ Object
-
#spreadsheet ⇒ Object
Mapping::Element structure.
- #worksheet(name) ⇒ Object
- #worksheet!(name) ⇒ Object
- #worksheet_schema(name) ⇒ Object
- #worksheets ⇒ Object (also: #_children_)
Methods inherited from Element
Constructor Details
#initialize(schema, filename) ⇒ Spreadsheet
Returns a new instance of Spreadsheet.
7 8 9 10 11 12 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 7 def initialize(schema, filename) super(schema, nil) @worksheets = {} @input_file = filename ROO.load(filename) end |
Instance Attribute Details
#input_file ⇒ Object (readonly)
Returns the value of attribute input_file.
5 6 7 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 5 def input_file @input_file end |
Instance Method Details
#map ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 14 def map schema.sorted_worksheets.each do |worksheet_schema| next unless ROO.roo.sheets.include? worksheet_schema.source_name worksheet!(worksheet_schema) end self end |
#spreadsheet ⇒ Object
Mapping::Element structure
33 34 35 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 33 def spreadsheet self end |
#worksheet(name) ⇒ Object
42 43 44 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 42 def worksheet(name) @worksheets[worksheet_schema(name).name] end |
#worksheet!(name) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 46 def worksheet!(name) worksheet_schema = worksheet_schema(name) @worksheets[worksheet_schema.name] || begin @worksheets[worksheet_schema.name] = mapping = Mapping::Worksheet.new(worksheet_schema, self) mapping.map end end |
#worksheet_schema(name) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 22 def worksheet_schema(name) case name when Schema::Worksheet then name when String, Symbol then schema.worksheet[name] else raise ArgumentError end end |
#worksheets ⇒ Object Also known as: _children_
37 38 39 |
# File 'lib/spread2rdf/mapping/spreadsheet.rb', line 37 def worksheets @worksheets.values end |