Class: Luoma::Lambda

Inherits:
Expression show all
Defined in:
lib/luoma/expression.rb,
sig/luoma/expression.rbs

Instance Attribute Summary

Attributes inherited from Expression

#span, #token

Instance Method Summary collapse

Constructor Details

#initialize(token, params, expr) ⇒ Lambda

(t_token, Array, Expression) -> void

Parameters:



723
724
725
726
727
728
# File 'lib/luoma/expression.rb', line 723

def initialize(token, params, expr)
  super(token)
  @params = params
  @expr = expr
  @span = Luoma.span(token, expr.span)
end

Instance Method Details

#childrenObject



735
736
737
# File 'lib/luoma/expression.rb', line 735

def children
  [@expr]
end

#evaluate(context) ⇒ Object

Signature:

  • (RenderContext) -> untyped



731
732
733
# File 'lib/luoma/expression.rb', line 731

def evaluate(context)
  ExpressionDrop.new(LambdaExpr.new(@params.map(&:value), @expr, context))
end

#scopeObject



739
740
741
# File 'lib/luoma/expression.rb', line 739

def scope
  @params
end

#to_sObject

Signature:

  • () -> String



744
745
746
# File 'lib/luoma/expression.rb', line 744

def to_s
  "(#{@params.join(", ")}) => #{@expr}"
end