Class: Luoma::SubExpression

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



566
567
568
569
570
# File 'lib/luoma/expression.rb', line 566

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



573
574
575
# File 'lib/luoma/expression.rb', line 573

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