Class: Liquid2::Negative
- Inherits:
-
Expression
- Object
- Expression
- Liquid2::Negative
- Defined in:
- lib/liquid2/expressions/arithmetic.rb
Overview
Prefix negation
Instance Attribute Summary
Attributes inherited from Expression
Instance Method Summary collapse
- #children ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(token, right) ⇒ Negative
constructor
A new instance of Negative.
Methods inherited from Expression
Constructor Details
#initialize(token, right) ⇒ Negative
Returns a new instance of Negative.
85 86 87 88 |
# File 'lib/liquid2/expressions/arithmetic.rb', line 85 def initialize(token, right) super(token) @right = right end |
Instance Method Details
#children ⇒ Object
100 |
# File 'lib/liquid2/expressions/arithmetic.rb', line 100 def children = [@right] |
#evaluate(context) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/liquid2/expressions/arithmetic.rb', line 90 def evaluate(context) right = context.evaluate(@right) value = Liquid2::Filters.to_decimal(right, default: nil) || context.env.undefined( "-(#{Liquid2.to_output_string(right)})", node: self ) value.send(:-@) end |