Class: FDK::ParsedInput
- Inherits:
-
Object
- Object
- FDK::ParsedInput
- Defined in:
- lib/fdk/support_classes.rb
Overview
ParsedInput stores raw input and can parse it as JSON (add extra formats as required)
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(raw_input:) ⇒ ParsedInput
constructor
A new instance of ParsedInput.
- #parsed ⇒ Object
Constructor Details
#initialize(raw_input:) ⇒ ParsedInput
Returns a new instance of ParsedInput.
25 26 27 |
# File 'lib/fdk/support_classes.rb', line 25 def initialize(raw_input:) @raw = raw_input end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
23 24 25 |
# File 'lib/fdk/support_classes.rb', line 23 def raw @raw end |
Instance Method Details
#as_json ⇒ Object
29 30 31 32 33 |
# File 'lib/fdk/support_classes.rb', line 29 def as_json @json ||= JSON.parse(raw) rescue JSON::ParserError @json = false end |
#parsed ⇒ Object
35 36 37 |
# File 'lib/fdk/support_classes.rb', line 35 def parsed as_json || raw end |