Class: JsonPath::NodeList
- Inherits:
-
Object
- Object
- JsonPath::NodeList
- Includes:
- Enumerable
- Defined in:
- lib/json_path/node_list.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(nodes) ⇒ NodeList
constructor
A new instance of NodeList.
- #paths ⇒ Object
- #query ⇒ Object
- #size ⇒ Object
- #values ⇒ Object
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
#nodes ⇒ Object (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 |
#paths ⇒ Object
25 26 27 |
# File 'lib/json_path/node_list.rb', line 25 def paths map(&:path) end |
#query ⇒ Object
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 |
#size ⇒ Object
29 30 31 |
# File 'lib/json_path/node_list.rb', line 29 def size nodes.size end |
#values ⇒ Object
21 22 23 |
# File 'lib/json_path/node_list.rb', line 21 def values map(&:value) end |