Class: JsonPath::Nodes::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/json_path/nodes/array.rb

Instance Attribute Summary

Attributes inherited from Base

#children, #path

Instance Method Summary collapse

Methods inherited from Base

#query

Constructor Details

#initialize(path, values) ⇒ Array

Returns a new instance of Array.



6
7
8
9
10
11
12
# File 'lib/json_path/nodes/array.rb', line 6

def initialize path, values
  super path
  @children = values
                .map.with_index do |value, i|
                  Nodes.parse "#{path}[#{i}]", value
                end
end

Instance Method Details

#valueObject



14
15
16
# File 'lib/json_path/nodes/array.rb', line 14

def value
  elements.map(&:value)
end