Class: JsonPath::NodeList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/json_path/node_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ NodeList

Returns a new instance of NodeList.



7
8
9
# File 'lib/json_path/node_list.rb', line 7

def initialize nodes
  @nodes = nodes
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



5
6
7
# File 'lib/json_path/node_list.rb', line 5

def nodes
  @nodes
end

Instance Method Details

#each(&block) ⇒ Object



17
18
19
# File 'lib/json_path/node_list.rb', line 17

def each(&block)
  nodes.each(&block)
end

#pathsObject



25
26
27
# File 'lib/json_path/node_list.rb', line 25

def paths
  map(&:path)
end

#queryObject



11
12
13
14
15
# File 'lib/json_path/node_list.rb', line 11

def query(...)
  nodes
    .flat_map { _1.query(...) }
    .then { self.class.new _1 }
end

#sizeObject



29
30
31
# File 'lib/json_path/node_list.rb', line 29

def size
  nodes.size
end

#valuesObject



21
22
23
# File 'lib/json_path/node_list.rb', line 21

def values
  map(&:value)
end