Class: JsonPath::Path

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_path) ⇒ Path



8
9
10
11
12
13
14
15
16
# File 'lib/json_path/path.rb', line 8

def initialize json_path
  if json_path.is_a? Path
    @string = json_path.string
    @proc = json_path.proc
  else
    @string = -json_path
    @proc = Parser.compile json_path
  end
end

Instance Attribute Details

#procObject (readonly)

Returns the value of attribute proc.



6
7
8
# File 'lib/json_path/path.rb', line 6

def proc
  @proc
end

#stringObject (readonly)

Returns the value of attribute string.



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

def string
  @string
end

Instance Method Details

#apply(node) ⇒ Object



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

def apply node
  proc.call node
end