Class: PersonifyLanguage::Function
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- PersonifyLanguage::Function
- Defined in:
- lib/personify/parser/personify_node_classes.rb
Instance Method Summary collapse
Instance Method Details
#eval(env = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/personify/parser/personify_node_classes.rb', line 84 def eval(env={}) if env.respond_to?(:allow_method?) && env.allow_method?(key.to_s) fn = env.method(key.to_s) else fn = self.key.eval(env) end if fn && fn.respond_to?(:call) params = self.function_parameters(env) if fn.arity >= 0 params = params[0,fn.arity] end fn.call(*params) else fn end rescue StandardError return nil end |
#function_parameters(env) ⇒ Object
104 105 106 107 108 |
# File 'lib/personify/parser/personify_node_classes.rb', line 104 def function_parameters(env) values = parameters.eval(env) values << self.block.eval(env) if self.block.kind_of?(Block) values end |