Class: Bindy::Language::Function

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/bindy/language_interpreters.rb

Instance Method Summary collapse

Instance Method Details

#argumentsObject



29
30
31
32
33
34
35
36
37
# File 'lib/bindy/language_interpreters.rb', line 29

def arguments
  if arg_list.text_value.empty?
    []
  elsif arg_list.respond_to?(:to_a)
    arg_list.to_a 
  else
    [arg_list]
  end
end

#evaluate(context) ⇒ Object



21
22
23
# File 'lib/bindy/language_interpreters.rb', line 21

def evaluate(context)
  context.public_send name, *arguments.map { |a| a.evaluate context }
end

#nameObject



25
26
27
# File 'lib/bindy/language_interpreters.rb', line 25

def name
  identifier.text_value
end