Class: Liquid2::Positive

Inherits:
Expression show all
Defined in:
lib/liquid2/expressions/arithmetic.rb

Overview

Prefix positive

Instance Attribute Summary

Attributes inherited from Expression

#token

Instance Method Summary collapse

Methods inherited from Expression

#scope

Constructor Details

#initialize(token, right) ⇒ Positive

Returns a new instance of Positive.

Parameters:



106
107
108
109
# File 'lib/liquid2/expressions/arithmetic.rb', line 106

def initialize(token, right)
  super(token)
  @right = right
end

Instance Method Details

#childrenObject



121
# File 'lib/liquid2/expressions/arithmetic.rb', line 121

def children = [@right]

#evaluate(context) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/liquid2/expressions/arithmetic.rb', line 111

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