Class: JSONP3::Path::InfixExpression

Inherits:
Expression show all
Defined in:
lib/json_p3/path/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.



174
175
176
177
178
# File 'lib/json_p3/path/filter.rb', line 174

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

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



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

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



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

def right
  @right
end

Instance Method Details

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



188
189
190
191
192
193
# File 'lib/json_p3/path/filter.rb', line 188

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

#evaluate(_context) ⇒ Object



180
181
182
# File 'lib/json_p3/path/filter.rb', line 180

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

#hashObject



197
198
199
# File 'lib/json_p3/path/filter.rb', line 197

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

#to_sObject



184
185
186
# File 'lib/json_p3/path/filter.rb', line 184

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