Class: JSONP3::Selector

Inherits:
Object
  • Object
show all
Defined in:
lib/json_p3/selector.rb

Overview

Base class for all JSONPath selectors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, token) ⇒ Selector

Returns a new instance of Selector.



9
10
11
12
# File 'lib/json_p3/selector.rb', line 9

def initialize(env, token)
  @env = env
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/json_p3/selector.rb', line 7

def token
  @token
end

Instance Method Details

#resolve(_node) ⇒ Array<JSONPathNode>

Apply this selector to node.

Returns:



16
17
18
# File 'lib/json_p3/selector.rb', line 16

def resolve(_node)
  raise "selectors must implement resolve(node)"
end

#singular?Boolean

Return true if this selector is a singular selector.

Returns:

  • (Boolean)


21
22
23
# File 'lib/json_p3/selector.rb', line 21

def singular?
  false
end