Class: Rika::Formatters
- Inherits:
-
Object
- Object
- Rika::Formatters
- Defined in:
- lib/rika/formatters.rb
Overview
This module manages the formatters used to format the output of the Rika command line application.
Constant Summary collapse
- AWESOME_PRINT_FORMATTER =
->(object) { object.ai }
- INSPECT_FORMATTER =
->(object) { object.inspect }
- JSON_FORMATTER =
->(object) { object.to_json }
- PRETTY_JSON_FORMATTER =
->(object) { JSON.pretty_generate(object) }
- TO_S_FORMATTER =
->(object) { object.to_s }
- YAML_FORMATTER =
->(object) { object.to_yaml }
- FORMATTER_LOOKUP_TABLE =
A hash of formatters, keyed by the format character. The value is a lambda that takes the object to be formatted as a parameter.
{ 'a' => AWESOME_PRINT_FORMATTER, 'i' => INSPECT_FORMATTER, 'j' => JSON_FORMATTER, 'J' => PRETTY_JSON_FORMATTER, 't' => TO_S_FORMATTER, 'y' => YAML_FORMATTER }.freeze
- VALID_OPTION_CHARS =
FORMATTER_LOOKUP_TABLE.keys
Class Method Summary collapse
-
.get(option_char) ⇒ Lambda
Gets the formatter lambda for the given option character.
Class Method Details
.get(option_char) ⇒ Lambda
Gets the formatter lambda for the given option character.
35 36 37 |
# File 'lib/rika/formatters.rb', line 35 def self.get(option_char) FORMATTER_LOOKUP_TABLE.fetch(option_char) end |