Class: Twostroke::AST::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/twostroke/ast/array.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#line

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Array

Returns a new instance of Array.



5
6
7
8
# File 'lib/twostroke/ast/array.rb', line 5

def initialize(*args)
  @items = []
  super *args
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



3
4
5
# File 'lib/twostroke/ast/array.rb', line 3

def items
  @items
end

Instance Method Details

#collapseObject



10
11
12
# File 'lib/twostroke/ast/array.rb', line 10

def collapse
  self.class.new items: items.map(&:collapse)
end

#walk(&bk) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/twostroke/ast/array.rb', line 14

def walk(&bk)
  if yield self
    items.each do |item|
      item.walk &bk
    end
  end
end