Class: FunctiondefNode
- Inherits:
-
Object
- Object
- FunctiondefNode
- Defined in:
- lib/nodes.rb
Overview
Class for defining functions.
Instance Method Summary collapse
-
#evaluate(scope) ⇒ Object
Saves identifier with code-block and parameters in current scope.
-
#initialize(identifier, block, parameters = []) ⇒ FunctiondefNode
constructor
A new instance of FunctiondefNode.
Constructor Details
#initialize(identifier, block, parameters = []) ⇒ FunctiondefNode
Returns a new instance of FunctiondefNode.
108 109 110 111 112 |
# File 'lib/nodes.rb', line 108 def initialize(identifier, block, parameters = []) @identifier = identifier.value @parameters = parameters @block = block end |
Instance Method Details
#evaluate(scope) ⇒ Object
Saves identifier with code-block and parameters in current scope
115 116 117 118 |
# File 'lib/nodes.rb', line 115 def evaluate(scope) params = @parameters.map {|parameter| parameter.value} scope.set_function(@identifier, @block, params) end |