Class: Alephant::Support::JsonPathLookup
- Inherits:
-
Object
- Object
- Alephant::Support::JsonPathLookup
- Defined in:
- lib/alephant/support/jsonpath_lookup.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ JsonPathLookup
constructor
A new instance of JsonPathLookup.
- #lookup(msg) ⇒ Object
Constructor Details
#initialize(path) ⇒ JsonPathLookup
Returns a new instance of JsonPathLookup.
8 9 10 11 |
# File 'lib/alephant/support/jsonpath_lookup.rb', line 8 def initialize(path) @path = path @jsonpath = JsonPath.new(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/alephant/support/jsonpath_lookup.rb', line 7 def path @path end |
Instance Method Details
#lookup(msg) ⇒ Object
13 14 15 |
# File 'lib/alephant/support/jsonpath_lookup.rb', line 13 def lookup(msg) @jsonpath.on(JSON.parse(msg)).first end |