Class: JSONP3::Path::Segment

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

Overview

Base class for all JSONPath segments.

Direct Known Subclasses

ChildSegment, DescendantSegment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, token, selectors) ⇒ Segment

Returns a new instance of Segment.



10
11
12
13
14
# File 'lib/json_p3/path/segment.rb', line 10

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

Instance Attribute Details

#selectorsObject (readonly)

Returns the value of attribute selectors.



8
9
10
# File 'lib/json_p3/path/segment.rb', line 8

def selectors
  @selectors
end

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/json_p3/path/segment.rb', line 8

def token
  @token
end

Instance Method Details

#resolve(_nodes) ⇒ Array<Node>

Select the children of each node in nodes.

Returns:



18
19
20
# File 'lib/json_p3/path/segment.rb', line 18

def resolve(_nodes)
  raise "segments must implement resolve(nodes)"
end

#resolve_enum(_nodes) ⇒ Enumerable<Node>

Select the children of each node in nodes.

Returns:

  • (Enumerable<Node>)


24
25
26
# File 'lib/json_p3/path/segment.rb', line 24

def resolve_enum(_nodes)
  raise "segments must implement resolve_enum(nodes)"
end