Class: Spread2RDF::Mapping::Cell
- Defined in:
- lib/spread2rdf/mapping/cell.rb,
lib/spread2rdf/mapping/default_cell_mappings.rb
Defined Under Namespace
Modules: Default
Instance Attribute Summary collapse
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Attributes inherited from Element
Instance Method Summary collapse
-
#_children_ ⇒ Object
Element#children.
- #coord ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(sheet, parent, row) ⇒ Cell
constructor
A new instance of Cell.
- #map ⇒ Object
- #object ⇒ Object
- #object_of_column(name) ⇒ Object
- #value ⇒ Object
-
#value_of_column(name) ⇒ Object
for the DSL for column statement blocks.
Methods inherited from Element
Constructor Details
#initialize(sheet, parent, row) ⇒ Cell
Returns a new instance of Cell.
10 11 12 13 14 |
# File 'lib/spread2rdf/mapping/cell.rb', line 10 def initialize(sheet, parent, row) super(sheet, parent) @row = row map end |
Instance Attribute Details
#row ⇒ Object (readonly)
Returns the value of attribute row.
5 6 7 |
# File 'lib/spread2rdf/mapping/cell.rb', line 5 def row @row end |
Instance Method Details
#_children_ ⇒ Object
Element#children
126 127 128 |
# File 'lib/spread2rdf/mapping/cell.rb', line 126 def _children_ nil end |
#coord ⇒ Object
20 21 22 |
# File 'lib/spread2rdf/mapping/cell.rb', line 20 def coord Coord[column: schema.coord, row: row] end |
#empty? ⇒ Boolean
32 33 34 |
# File 'lib/spread2rdf/mapping/cell.rb', line 32 def empty? value.blank? end |
#map ⇒ Object
16 17 18 |
# File 'lib/spread2rdf/mapping/cell.rb', line 16 def map exec(&schema.block) unless empty? end |
#object ⇒ Object
28 29 30 |
# File 'lib/spread2rdf/mapping/cell.rb', line 28 def object @object ||= value && map_to_object(value) end |
#object_of_column(name) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/spread2rdf/mapping/cell.rb', line 110 def object_of_column(name) other_column = resource.column!(name) raise "couldn't find column #{name} when mapping #{self}" if other_column.nil? other_column.cell!(row).object end |
#value ⇒ Object
24 25 26 |
# File 'lib/spread2rdf/mapping/cell.rb', line 24 def value @value ||= worksheet.cell_value(coord) end |
#value_of_column(name) ⇒ Object
for the DSL for column statement blocks
102 103 104 105 106 107 108 |
# File 'lib/spread2rdf/mapping/cell.rb', line 102 def value_of_column(name) sheet_schema = parent.parent.schema other_column = sheet_schema.column(name) raise "couldn't find column #{name} when mapping #{self}" if other_column.nil? worksheet.cell_value(column: other_column.coord, row: row) end |