Class: Twostroke::AST::Function
- Defined in:
- lib/twostroke/ast/function.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#fnid ⇒ Object
Returns the value of attribute fnid.
-
#name ⇒ Object
Returns the value of attribute name.
-
#statements ⇒ Object
Returns the value of attribute statements.
Attributes inherited from Base
Instance Method Summary collapse
- #collapse ⇒ Object
-
#initialize(*args) ⇒ Function
constructor
A new instance of Function.
- #walk(&bk) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Function
Returns a new instance of Function.
5 6 7 8 9 |
# File 'lib/twostroke/ast/function.rb', line 5 def initialize(*args) @arguments = [] @statements = [] super *args end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/twostroke/ast/function.rb', line 3 def arguments @arguments end |
#fnid ⇒ Object
Returns the value of attribute fnid.
3 4 5 |
# File 'lib/twostroke/ast/function.rb', line 3 def fnid @fnid end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/twostroke/ast/function.rb', line 3 def name @name end |
#statements ⇒ Object
Returns the value of attribute statements.
3 4 5 |
# File 'lib/twostroke/ast/function.rb', line 3 def statements @statements end |
Instance Method Details
#collapse ⇒ Object
11 12 13 |
# File 'lib/twostroke/ast/function.rb', line 11 def collapse self.class.new name: name, arguments: arguments, statements: statements.reject(&:nil?).map(&:collapse), fnid: fnid end |
#walk(&bk) ⇒ Object
15 16 17 18 19 |
# File 'lib/twostroke/ast/function.rb', line 15 def walk(&bk) if yield self statements.each { |s| s.walk &bk } end end |