Class: Nous::Serializer
Defined Under Namespace
Classes: SerializationError
Constant Summary collapse
- FORMATS =
%i[text json].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(pages:, format: :text) ⇒ Serializer
constructor
A new instance of Serializer.
Methods inherited from Command
Constructor Details
#initialize(pages:, format: :text) ⇒ Serializer
Returns a new instance of Serializer.
11 12 13 14 15 |
# File 'lib/nous/serializer.rb', line 11 def initialize(pages:, format: :text) @pages = pages @format = format.to_sym validate_format! end |
Instance Method Details
#call ⇒ Object
17 18 19 20 |
# File 'lib/nous/serializer.rb', line 17 def call output = (format == :json) ? serialize_json : serialize_text success(payload: output) end |