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.
7 8 9 |
# File 'lib/fdk/support_classes.rb', line 7 def initialize(raw_input:) @raw = raw_input end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/fdk/support_classes.rb', line 5 def raw @raw end |
Instance Method Details
#as_json ⇒ Object
11 12 13 14 15 |
# File 'lib/fdk/support_classes.rb', line 11 def as_json @json ||= JSON.parse(raw) rescue JSON::ParserError @json = false end |
#parsed ⇒ Object
17 18 19 |
# File 'lib/fdk/support_classes.rb', line 17 def parsed as_json || raw end |