Class: JSONP3::Path::QueryExpression

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

Overview

Base class for all embedded filter queries

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.



298
299
300
301
# File 'lib/json_p3/path/filter.rb', line 298

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

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

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



311
312
313
314
315
# File 'lib/json_p3/path/filter.rb', line 311

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

#evaluate(_context) ⇒ Object



303
304
305
# File 'lib/json_p3/path/filter.rb', line 303

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

#hashObject



319
320
321
# File 'lib/json_p3/path/filter.rb', line 319

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

#to_sObject



307
308
309
# File 'lib/json_p3/path/filter.rb', line 307

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