Class: Spread2RDF::Mapping::Element
- Inherits:
-
Object
- Object
- Spread2RDF::Mapping::Element
- Extended by:
- Forwardable
- Defined in:
- lib/spread2rdf/mapping/element.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#_children_ ⇒ Object
children.
- #empty? ⇒ Boolean
-
#graph ⇒ Object
(also: #to_rdf)
RDF graph.
-
#initialize(schema, parent) ⇒ Element
constructor
A new instance of Element.
- #to_s ⇒ Object
Constructor Details
#initialize(schema, parent) ⇒ Element
Returns a new instance of Element.
13 14 15 16 17 |
# File 'lib/spread2rdf/mapping/element.rb', line 13 def initialize(schema, parent) @graph = RDF::Repository.new @schema = schema @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/spread2rdf/mapping/element.rb', line 9 def parent @parent end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
8 9 10 |
# File 'lib/spread2rdf/mapping/element.rb', line 8 def schema @schema end |
Instance Method Details
#_children_ ⇒ Object
children
26 27 28 |
# File 'lib/spread2rdf/mapping/element.rb', line 26 def _children_ raise NotImplementedError, 'subclasses must implement this method' end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/spread2rdf/mapping/element.rb', line 30 def empty? _children_.empty? or _children_.all?(&:empty?) end |
#graph ⇒ Object Also known as: to_rdf
RDF graph
37 38 39 40 41 42 43 |
# File 'lib/spread2rdf/mapping/element.rb', line 37 def graph if _children_ _children_.inject(@graph.clone) { |graph, child| graph << child.graph } else @graph end end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/spread2rdf/mapping/element.rb', line 19 def to_s "#{self.class.name.split('::').last}-mapping of #{schema}" end |