class Spread2RDF::Mapping::Element
Attributes
parent[R]
schema[R]
Public Class Methods
new(schema, parent)
click to toggle source
# File lib/spread2rdf/mapping/element.rb, line 13 def initialize(schema, parent) @graph = RDF::Repository.new @schema = schema @parent = parent end
Public Instance Methods
_children_()
click to toggle source
children
# File lib/spread2rdf/mapping/element.rb, line 26 def _children_ raise NotImplementedError, 'subclasses must implement this method' end
empty?()
click to toggle source
# File lib/spread2rdf/mapping/element.rb, line 30 def empty? _children_.empty? or _children_.all?(&:empty?) end
graph()
click to toggle source
RDF graph
# 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
Also aliased as: to_rdf
to_s()
click to toggle source
# File lib/spread2rdf/mapping/element.rb, line 19 def to_s "#{self.class.name.split('::').last}-mapping of #{schema}" end
Private Instance Methods
add_statement(*args)
click to toggle source
# File lib/spread2rdf/mapping/element.rb, line 48 def add_statement(*args) args = args.first if args.count == 1 and args.first.is_a? Array #puts "adding statement: #{args.inspect}" raise "internal error: trying to add a bad triple with nil value: #{args}" if args.count != 3 or args.one? { |arg| arg.nil? } @graph << RDF::Statement.new(*args) end
Also aliased as: statement
add_statements(*args)
click to toggle source
# File lib/spread2rdf/mapping/element.rb, line 56 def add_statements(*args) args = args.first if args.count == 1 and args.first.is_a? Array args.each { |arg| statement(arg) } end
Also aliased as: statements