Class: Expressive::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/expressive.rb

Direct Known Subclasses

Syntax

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Function

Returns a new instance of Function.



105
106
107
# File 'lib/expressive.rb', line 105

def initialize(&block)
  @block = block
end

Instance Method Details

#call(scope, statements) ⇒ Object



109
110
111
112
# File 'lib/expressive.rb', line 109

def call(scope, statements)
  parameters = statements.map {|c| c.eval(scope)}
  @block.call(*parameters)
end