Class: IqRdf::BlankNode
- Inherits:
-
Node
- Object
- Node
- IqRdf::BlankNode
show all
- Defined in:
- lib/iq_rdf/blank_node.rb
Instance Attribute Summary collapse
Attributes inherited from Node
#lang, #nodes
Instance Method Summary
collapse
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
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
#build_predicate_with_ns(namespace, *args, &block) ⇒ Object
#build_xml(xml, &block) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/iq_rdf/blank_node.rb', line 47
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(options = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/iq_rdf/blank_node.rb', line 29
def to_s(options = {})
base_indent = options[:indent] || ""
predicate_indent = base_indent + "".ljust(4)
predicates = nodes.map { |p| format_predicate(p, indent: predicate_indent, lang: options[:lang]) }
.join(";\n")
"[\n#{predicates}\n#{base_indent} ]"
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
|