Class: Ichnite::Formatters::KeyValue
- Inherits:
-
Object
- Object
- Ichnite::Formatters::KeyValue
- Defined in:
- lib/ichnite/formatters.rb
Instance Method Summary collapse
Instance Method Details
#call(data) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/ichnite/formatters.rb', line 7 def call(data) fields = fields_to_display(data) event = fields.map { |key| format(key, data[key]) } event.join(' ') end |
#fields_to_display(data) ⇒ Object
14 15 16 |
# File 'lib/ichnite/formatters.rb', line 14 def fields_to_display(data) data.keys end |
#format(key, value) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ichnite/formatters.rb', line 18 def format(key, value) if key == :error # Exactly preserve the previous output # Parsing this can be ambigious if the error messages contains # a single quote value = "'#{value}'" elsif value.is_a? Float value = Kernel.format('%.2f', value) end "#{key}=#{value}" end |