Class: Dicey::CLI::Formatters::BaseMapFormatter Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dicey/cli/formatters/base_map_formatter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is abstract.

Base formatter for outputting in formats which are map- (or object-) like. Can add an optional description into the result.

Direct Known Subclasses

JSONFormatter, YAMLFormatter

Instance Method Summary collapse

Instance Method Details

#call(hash, description = nil) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • hash (Hash{Object => Object})
  • description (String) (defaults to: nil)

    text to add to result as an extra key

Returns:

  • (String)


14
15
16
17
18
19
20
21
# File 'lib/dicey/cli/formatters/base_map_formatter.rb', line 14

def call(hash, description = nil)
  hash = hash.transform_keys { to_primitive(_1) }
  hash.transform_values! { to_primitive(_1) }
  output = {}
  output["description"] = description if description
  output["results"] = hash
  output.public_send(self.class::METHOD)
end