Class: Luoma::AddExpression

Inherits:
InfixExpression 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

Methods inherited from InfixExpression

#children, #initialize

Methods inherited from Expression

#children, #initialize, #scope

Constructor Details

This class inherits a constructor from Luoma::InfixExpression

Instance Method Details

#evaluate(context) ⇒ Object

Signature:

  • (RenderContext) -> untyped



552
553
554
555
556
# File 'lib/luoma/expression.rb', line 552

def evaluate(context)
  left = context.env.to_numeric(@left.evaluate(context), context, default: :nothing)
  right = context.env.to_numeric(@right.evaluate(context), context, default: :nothing)
  left == :nothing || right == :nothing ? :nothing : left + right # steep:ignore
end

#to_sObject

Signature:

  • () -> String



559
560
561
# File 'lib/luoma/expression.rb', line 559

def to_s
  "#{@left} + #{@right}"
end