Class: JSONP3::RelativeQueryExpression

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

Overview

An embedded query starting at the current node.

Instance Attribute Summary

Attributes inherited from QueryExpression

#query

Attributes inherited from Expression

#token

Instance Method Summary collapse

Methods inherited from QueryExpression

#==, #hash, #initialize

Methods inherited from Expression

#initialize

Constructor Details

This class inherits a constructor from JSONP3::QueryExpression

Instance Method Details

#evaluate(context) ⇒ Object



324
325
326
327
328
329
330
# File 'lib/json_p3/filter.rb', line 324

def evaluate(context)
  unless context.current.is_a?(Array) || context.current.is_a?(Hash)
    return @query.empty? ? context.current : JSONPathNodeList.new
  end

  @query.find(context.current)
end

#to_sObject



332
333
334
# File 'lib/json_p3/filter.rb', line 332

def to_s
  "@#{@query.to_s[1..]}"
end