Class: Beckett::Node::Base
- Inherits:
-
Object
- Object
- Beckett::Node::Base
- Defined in:
- lib/beckett/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
- #<<(nodes) ⇒ Object
-
#initialize(node) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(node) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 |
# File 'lib/beckett/node.rb', line 17 def initialize(node) @node = node @children = [] @position = $position $position += 1 end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
15 16 17 |
# File 'lib/beckett/node.rb', line 15 def children @children end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
15 16 17 |
# File 'lib/beckett/node.rb', line 15 def node @node end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
15 16 17 |
# File 'lib/beckett/node.rb', line 15 def position @position end |
Instance Method Details
#<<(nodes) ⇒ Object
36 37 38 |
# File 'lib/beckett/node.rb', line 36 def <<(nodes) @children += ([nodes].flatten) end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/beckett/node.rb', line 24 def inspect "<#{node_name} position=#{position}>" end |
#to_h ⇒ Object
32 33 34 |
# File 'lib/beckett/node.rb', line 32 def to_h raise NotImplementedError end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/beckett/node.rb', line 28 def to_s inspect end |