Class: JSONP3::InfixExpression

Inherits:
Expression show all
Defined in:
lib/json_p3/filter.rb

Overview

Base class for expression with a left expression, operator and right expression.

Instance Attribute Summary collapse

Attributes inherited from Expression

#token

Instance Method Summary collapse

Constructor Details

#initialize(token, left, right) ⇒ InfixExpression

Returns a new instance of InfixExpression.



172
173
174
175
176
# File 'lib/json_p3/filter.rb', line 172

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

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



170
171
172
# File 'lib/json_p3/filter.rb', line 170

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



170
171
172
# File 'lib/json_p3/filter.rb', line 170

def right
  @right
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



186
187
188
189
190
191
# File 'lib/json_p3/filter.rb', line 186

def ==(other)
  self.class == other.class &&
    @left == other.left &&
    @right == other.right &&
    @token == other.token
end

#evaluate(_context) ⇒ Object



178
179
180
# File 'lib/json_p3/filter.rb', line 178

def evaluate(_context)
  raise "infix expressions must implement `evaluate(context)`"
end

#hashObject



195
196
197
# File 'lib/json_p3/filter.rb', line 195

def hash
  [@left, @right, @token].hash
end

#to_sObject



182
183
184
# File 'lib/json_p3/filter.rb', line 182

def to_s
  raise "infix expressions must implement `to_s`"
end