Class: Lutaml::Qea::Validation::Formatters::JsonFormatter
- Inherits:
-
Object
- Object
- Lutaml::Qea::Validation::Formatters::JsonFormatter
- Defined in:
- lib/lutaml/qea/validation/formatters/json_formatter.rb
Overview
Formats validation results as JSON for machine consumption
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#format ⇒ String
Formats the validation result as JSON.
-
#initialize(result: nil, **options) ⇒ JsonFormatter
constructor
Creates a new JSON formatter.
Constructor Details
#initialize(result: nil, **options) ⇒ JsonFormatter
Creates a new JSON formatter
26 27 28 29 30 31 |
# File 'lib/lutaml/qea/validation/formatters/json_formatter.rb', line 26 def initialize(result: nil, **) @result = result @options = { pretty: false, }.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/lutaml/qea/validation/formatters/json_formatter.rb', line 19 def @options end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
19 20 21 |
# File 'lib/lutaml/qea/validation/formatters/json_formatter.rb', line 19 def result @result end |
Instance Method Details
#format ⇒ String
Formats the validation result as JSON
36 37 38 39 40 41 42 43 44 |
# File 'lib/lutaml/qea/validation/formatters/json_formatter.rb', line 36 def format data = build_data if [:pretty] JSON.pretty_generate(data) else JSON.generate(data) end end |