class Rubasteme::AST::BranchNode

Public Class Methods

new(initial_size = nil) click to toggle source
Calls superclass method Rubasteme::AST::Node::new
# File lib/rubasteme/ast/branch_node.rb, line 8
def initialize(initial_size = nil)
  super(nil)
  @nodes = initial_size.nil? ? [] : Array.new(initial_size)
end

Public Instance Methods

<<(node) click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 40
def <<(node)
  @nodes << node
end
[](index) click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 32
def [](index)
  @nodes[index]
end
[]=(index, node) click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 36
def []=(index, node)
  @nodes[index] = node
end
each(&blk) click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 23
def each(&blk)
  if block_given?
    @nodes.each(&blk)
    self
  else
    @nodes.each
  end
end
size() click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 13
def size
  @nodes.size
end
to_a() click to toggle source
# File lib/rubasteme/ast/branch_node.rb, line 17
def to_a
  [type].concat(@nodes.map(&:to_a))
end