Class: JSONP3::Selector
- Inherits:
-
Object
- Object
- JSONP3::Selector
- Defined in:
- lib/json_p3/selector.rb
Overview
Base class for all JSONPath selectors
Direct Known Subclasses
FilterSelector, IndexSelector, NameSelector, SliceSelector, WildcardSelector
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(env, token) ⇒ Selector
constructor
A new instance of Selector.
-
#resolve(_node) ⇒ Array<JSONPathNode>
Apply this selector to node.
-
#resolve_enum(node) ⇒ Enumerable<JSONPathNode>
Apply this selector to node.
-
#singular? ⇒ Boolean
Return true if this selector is a singular selector.
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
#token ⇒ Object (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.
16 17 18 |
# File 'lib/json_p3/selector.rb', line 16 def resolve(_node) raise "selectors must implement resolve(node)" end |
#resolve_enum(node) ⇒ Enumerable<JSONPathNode>
Apply this selector to node.
22 23 24 |
# File 'lib/json_p3/selector.rb', line 22 def resolve_enum(node) resolve(node) end |
#singular? ⇒ Boolean
Return true if this selector is a singular selector.
27 28 29 |
# File 'lib/json_p3/selector.rb', line 27 def singular? false end |