Class: JsonDataExtractor::ExtractionInstruction
- Defined in:
- lib/json_data_extractor/extraction_instruction.rb
Overview
Represents a single field extraction instruction
Instance Attribute Summary collapse
-
#compiled_path ⇒ Object
readonly
Returns the value of attribute compiled_path.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #extract(data) ⇒ Object
-
#initialize(key:, element:, compiled_path:) ⇒ ExtractionInstruction
constructor
A new instance of ExtractionInstruction.
Constructor Details
#initialize(key:, element:, compiled_path:) ⇒ ExtractionInstruction
Returns a new instance of ExtractionInstruction.
8 9 10 11 12 |
# File 'lib/json_data_extractor/extraction_instruction.rb', line 8 def initialize(key:, element:, compiled_path:) @key = key @element = element @compiled_path = compiled_path end |
Instance Attribute Details
#compiled_path ⇒ Object (readonly)
Returns the value of attribute compiled_path.
6 7 8 |
# File 'lib/json_data_extractor/extraction_instruction.rb', line 6 def compiled_path @compiled_path end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
6 7 8 |
# File 'lib/json_data_extractor/extraction_instruction.rb', line 6 def element @element end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/json_data_extractor/extraction_instruction.rb', line 6 def key @key end |
Instance Method Details
#extract(data) ⇒ Object
14 15 16 17 18 |
# File 'lib/json_data_extractor/extraction_instruction.rb', line 14 def extract(data) return element.fetch_default_value if compiled_path.nil? compiled_path.on(data) end |