Class: JMESPath::Nodes::Field Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Method Summary collapse
- #chain(other) ⇒ Object private
- #chains_with?(other) ⇒ Boolean private
-
#initialize(key) ⇒ Field
constructor
private
A new instance of Field.
- #visit(value) ⇒ Object private
Methods inherited from Node
Constructor Details
#initialize(key) ⇒ Field
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Field.
6 7 8 9 |
# File 'lib/jmespath/nodes/field.rb', line 6 def initialize(key) @key = key @key_sym = key.respond_to?(:to_sym) ? key.to_sym : nil end |
Instance Method Details
#chain(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/jmespath/nodes/field.rb', line 30 def chain(other) ChainedField.new([@key, *other.keys]) end |
#chains_with?(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/jmespath/nodes/field.rb', line 26 def chains_with?(other) other.is_a?(Field) end |
#visit(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jmespath/nodes/field.rb', line 11 def visit(value) if value.respond_to?(:to_ary) && @key.is_a?(Integer) value.to_ary[@key] elsif value.respond_to?(:to_hash) value = value.to_hash if !(v = value[@key]).nil? v elsif @key_sym && !(v = value[@key_sym]).nil? v end elsif value.is_a?(Struct) && value.respond_to?(@key) value[@key] end end |