Class: Twostroke::AST::New

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

Instance Attribute Summary collapse

Attributes inherited from Base

#line

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ New

Returns a new instance of New.



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

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

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

#calleeObject

Returns the value of attribute callee.



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

def callee
  @callee
end

Instance Method Details

#collapseObject



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

def collapse
  self.class.new callee: callee.collapse, arguments: arguments.map(&:collapse)
end

#walk(&bk) ⇒ Object



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

def walk(&bk)
  if yield self
    callee.walk &bk
    arguments.each { |a| a.walk &bk }
  end
end