Class: Taverna::Baclava::Node
- Inherits:
-
Object
- Object
- Taverna::Baclava::Node
- Defined in:
- lib/baclava/node.rb
Overview
An annotated data value.
Instance Attribute Summary collapse
-
#annotation ⇒ Object
A list of annotations on this Node.
-
#syntactic_type ⇒ Object
readonly
The syntactic type of this node.
-
#value ⇒ Object
The value of this Node.
Class Method Summary collapse
-
.extract_node_data(node) ⇒ Object
Extract the data value(s) from this Node and return them in the same structure as the given Node.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Test for equality between this and another Node.
-
#initialize(value = nil, annotation = []) ⇒ Node
constructor
Create a new Node.
Constructor Details
#initialize(value = nil, annotation = []) ⇒ Node
Create a new Node. If a list is passed in as the value then it is recursively processed into a list of Nodes.
50 51 52 53 54 |
# File 'lib/baclava/node.rb', line 50 def initialize(value = nil, annotation = []) @syntactic_type = "" @value = value.nil? ? nil : _set_value(value) @annotation = annotation end |
Instance Attribute Details
#annotation ⇒ Object
A list of annotations on this Node.
43 44 45 |
# File 'lib/baclava/node.rb', line 43 def annotation @annotation end |
#syntactic_type ⇒ Object (readonly)
The syntactic type of this node.
46 47 48 |
# File 'lib/baclava/node.rb', line 46 def syntactic_type @syntactic_type end |
#value ⇒ Object
The value of this Node.
40 41 42 |
# File 'lib/baclava/node.rb', line 40 def value @value end |
Class Method Details
.extract_node_data(node) ⇒ Object
Extract the data value(s) from this Node and return them in the same structure as the given Node.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/baclava/node.rb', line 69 def Node.extract_node_data(node) case node when Hash hash = {} node.each { |k, v| hash[k] = Node.extract_node_data(v.value) } hash when Array list = [] node.each { |n| list << Node.extract_node_data(n.value) } list when Taverna::Baclava::Node Node.extract_node_data(node.value) else node end end |
Instance Method Details
#==(other) ⇒ Object
Test for equality between this and another Node.
63 64 65 |
# File 'lib/baclava/node.rb', line 63 def ==(other) @value == other.value and @annotation == other.annotation end |