Class: JSONP3::QueryExpression

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

Overview

Base class for all embedded filter queries

Direct Known Subclasses

RelativeQueryExpression, RootQueryExpression

Instance Attribute Summary collapse

Attributes inherited from Expression

#token

Instance Method Summary collapse

Constructor Details

#initialize(token, query) ⇒ QueryExpression

Returns a new instance of QueryExpression.



296
297
298
299
# File 'lib/json_p3/filter.rb', line 296

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

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



294
295
296
# File 'lib/json_p3/filter.rb', line 294

def query
  @query
end

Instance Method Details

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



309
310
311
312
313
# File 'lib/json_p3/filter.rb', line 309

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

#evaluate(_context) ⇒ Object



301
302
303
# File 'lib/json_p3/filter.rb', line 301

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

#hashObject



317
318
319
# File 'lib/json_p3/filter.rb', line 317

def hash
  [@query, @token].hash
end

#to_sObject



305
306
307
# File 'lib/json_p3/filter.rb', line 305

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