Class: JsonPath::Nodes::Base

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

Direct Known Subclasses

Array, False, Null, Number, Object, String, True

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/json_path/nodes/base.rb', line 10

def initialize path
  @path = path
  @children = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



8
9
10
# File 'lib/json_path/nodes/base.rb', line 8

def children
  @children
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#query(json_path) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/json_path/nodes/base.rb', line 15

def query json_path
  json_path = Path.new json_path

  json_path
    .apply(self)
    .then { NodeList.new _1 }
end