Class: Beckett::Node::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/beckett/node.rb

Direct Known Subclasses

Element, Root, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject (readonly)

Returns the value of attribute children.



15
16
17
# File 'lib/beckett/node.rb', line 15

def children
  @children
end

#nodeObject (readonly)

Returns the value of attribute node.



15
16
17
# File 'lib/beckett/node.rb', line 15

def node
  @node
end

#positionObject (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

#inspectObject



24
25
26
# File 'lib/beckett/node.rb', line 24

def inspect
  "<#{node_name} position=#{position}>"
end

#to_hObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/beckett/node.rb', line 32

def to_h
  raise NotImplementedError
end

#to_sObject



28
29
30
# File 'lib/beckett/node.rb', line 28

def to_s
  inspect
end