Class: Spread2RDF::Mapping::Resource
- Includes:
- ResourceCreation
- Defined in:
- lib/spread2rdf/mapping/resource.rb
Instance Attribute Summary collapse
-
#row_range ⇒ Object
readonly
Returns the value of attribute row_range.
Attributes inherited from Element
Instance Method Summary collapse
- #column(name) ⇒ Object
- #column!(name) ⇒ Object
- #column_schema(name) ⇒ Object
-
#columns ⇒ Object
(also: #_children_)
Mapping::Element structure.
-
#initialize(sheet, parent, row_range) ⇒ Resource
constructor
A new instance of Resource.
- #map ⇒ Object
- #subject ⇒ Object
Methods included from ResourceCreation
Methods inherited from Element
Constructor Details
#initialize(sheet, parent, row_range) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 14 |
# File 'lib/spread2rdf/mapping/resource.rb', line 9 def initialize(sheet, parent, row_range) super(sheet, parent) @columns = {} @row_range = row_range map end |
Instance Attribute Details
#row_range ⇒ Object (readonly)
Returns the value of attribute row_range.
5 6 7 |
# File 'lib/spread2rdf/mapping/resource.rb', line 5 def row_range @row_range end |
Instance Method Details
#column(name) ⇒ Object
62 63 64 |
# File 'lib/spread2rdf/mapping/resource.rb', line 62 def column(name) @columns[column_schema(name).name] end |
#column!(name) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/spread2rdf/mapping/resource.rb', line 66 def column!(name) column_schema = column_schema(name) @columns[column_schema.name] ||= case column_schema when Schema::Column then Column.new(column_schema, self) when Schema::ColumnBlock then ColumnBlock.new(column_schema, self).map end end |
#column_schema(name) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/spread2rdf/mapping/resource.rb', line 74 def column_schema(name) case name when Schema::Column, Schema::ColumnBlock then name when String, Symbol then schema.column(name) else raise ArgumentError end end |
#columns ⇒ Object Also known as: _children_
Mapping::Element structure
57 58 59 |
# File 'lib/spread2rdf/mapping/resource.rb', line 57 def columns @columns.values end |
#map ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/spread2rdf/mapping/resource.rb', line 16 def map #puts "processing #{self} in #{row_range}" object_columns = parent.schema.columns - [parent.schema.subject_column] object_columns.each { |column| column!(column) } subject_description unless empty? self end |
#subject ⇒ Object
29 30 31 |
# File 'lib/spread2rdf/mapping/resource.rb', line 29 def subject @subject ||= create_resource end |