Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/node.rb
Instance Attribute Summary collapse
-
#decision ⇒ Object
readonly
Returns the value of attribute decision.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#pred ⇒ Object
readonly
Returns the value of attribute pred.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Node
constructor
A new instance of Node.
- #true?(features) ⇒ Boolean
Constructor Details
#initialize(xml) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/node.rb', line 7 def initialize(xml) children = xml.children @pred = Predicate.new(children[0]) @decision = xml.attribute('score').to_s return if children.count == 1 @left = Node.new(children[1]) if children[1] @right = Node.new(children[2]) if children[2] end |
Instance Attribute Details
#decision ⇒ Object (readonly)
Returns the value of attribute decision.
5 6 7 |
# File 'lib/node.rb', line 5 def decision @decision end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
5 6 7 |
# File 'lib/node.rb', line 5 def left @left end |
#pred ⇒ Object (readonly)
Returns the value of attribute pred.
5 6 7 |
# File 'lib/node.rb', line 5 def pred @pred end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
5 6 7 |
# File 'lib/node.rb', line 5 def right @right end |
Instance Method Details
#true?(features) ⇒ Boolean
18 19 20 |
# File 'lib/node.rb', line 18 def true?(features) @pred.nil? || @pred.true?(features) end |