Class: IqRdf::Node
- Inherits:
-
Object
- Object
- IqRdf::Node
- Defined in:
- lib/iq_rdf/node.rb
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#<<(node) ⇒ Object
You can add Nodes (Uris, Blank Nodes, Predicates), Literals and Collections So a Node has the following structure: <node> <uri> or <node> <literal> (tuple) <node> <predicate> == <node> (<predicate_node> <predicate.nodes>) (triples).
- #build_full_uri_predicate(uri, *args, &block) ⇒ Object
-
#initialize(lang = nil) ⇒ Node
constructor
A new instance of Node.
- #is_subject? ⇒ Boolean
- #method_missing(method_name, *args, &block) ⇒ Object
- #xml_lang ⇒ Object
Constructor Details
#initialize(lang = nil) ⇒ Node
Returns a new instance of Node.
20 21 22 23 |
# File 'lib/iq_rdf/node.rb', line 20 def initialize(lang = nil) @nodes = [] @lang = lang end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/iq_rdf/node.rb', line 34 def method_missing(method_name, *args, &block) if (namespace_class = Namespace.find_namespace_class(method_name)) return IqRdf::PredicateNamespace.new(self, namespace_class) # some_node.>namespace<... else return IqRdf::PredicateNamespace.new(self, IqRdf::Default).build_predicate(method_name, *args, &block) # some_node.>predicate<() end end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
18 19 20 |
# File 'lib/iq_rdf/node.rb', line 18 def lang @lang end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
17 18 19 |
# File 'lib/iq_rdf/node.rb', line 17 def nodes @nodes end |
Instance Method Details
#<<(node) ⇒ Object
You can add Nodes (Uris, Blank Nodes, Predicates), Literals and Collections So a Node has the following structure:
<node> <uri> or <node> <literal> (tuple)
<node> <predicate> == <node> (<predicate_node> <predicate.nodes>) (triples)
29 30 31 32 |
# File 'lib/iq_rdf/node.rb', line 29 def <<(node) raise ArgumentError, "#{node.inspect} is no IqRdf::Node or a IqRdf::Literal or a IqRdf::Collection" unless node.is_a?(IqRdf::Node) || node.is_a?(IqRdf::Literal) || node.is_a?(IqRdf::Collection) @nodes << node end |
#build_full_uri_predicate(uri, *args, &block) ⇒ Object
46 47 48 49 50 |
# File 'lib/iq_rdf/node.rb', line 46 def build_full_uri_predicate(uri, *args, &block) raise ArgumentError, "uri musst be an ::URI" unless uri.is_a?(::URI) IqRdf::PredicateNamespace.new(self, Namespace.dummy_empty_namespace).build_predicate(uri, *args, &block) end |
#is_subject? ⇒ Boolean
42 43 44 |
# File 'lib/iq_rdf/node.rb', line 42 def is_subject?() false end |
#xml_lang ⇒ Object
52 53 54 |
# File 'lib/iq_rdf/node.rb', line 52 def xml_lang @lang && (@lang == :none ? "" : @lang) end |