Class: IqRdf::BlankNode
Instance Attribute Summary collapse
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
Attributes inherited from Node
Instance Method Summary collapse
- #build_predicate(*args, &block) ⇒ Object
- #build_xml(xml, &block) ⇒ Object
-
#initialize(node_id = nil) ⇒ BlankNode
constructor
A new instance of BlankNode.
- #to_s(parent_lang = nil) ⇒ Object
- #to_turtle(parent_lang = nil) ⇒ Object
Methods inherited from Node
#<<, #build_full_uri_predicate, #is_subject?, #method_missing, #xml_lang
Constructor Details
#initialize(node_id = nil) ⇒ BlankNode
Returns a new instance of BlankNode.
20 21 22 23 |
# File 'lib/iq_rdf/blank_node.rb', line 20 def initialize(node_id = nil) super @node_id = node_id end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class IqRdf::Node
Instance Attribute Details
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
18 19 20 |
# File 'lib/iq_rdf/blank_node.rb', line 18 def node_id @node_id end |
Instance Method Details
#build_predicate(*args, &block) ⇒ Object
33 34 35 |
# File 'lib/iq_rdf/blank_node.rb', line 33 def build_predicate(*args, &block) IqRdf::PredicateNamespace.new(self, IqRdf::Default).build_predicate(*args, &block) end |
#build_xml(xml, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/iq_rdf/blank_node.rb', line 37 def build_xml(xml, &block) block.call({}, lambda { attrs = {} attrs["xml:lang"] = self.lang if self.lang xml.rdf(:Description, attrs) do self.nodes.each do |predicate| predicate.build_xml(xml) end end }) end |
#to_s(parent_lang = nil) ⇒ Object
29 30 31 |
# File 'lib/iq_rdf/blank_node.rb', line 29 def to_s(parent_lang = nil) "[\n#{(nodes.map{|pred| "#{pred} #{pred.nodes.map{|o| o.to_s(pred.lang || parent_lang)}.join(", ")}"}.join(";\n")).gsub(/^/, " ")}\n]" end |
#to_turtle(parent_lang = nil) ⇒ Object
25 26 27 |
# File 'lib/iq_rdf/blank_node.rb', line 25 def to_turtle(parent_lang = nil) end |