Class: Erlash::HashExperimentalFormatter

Inherits:
TemplateFormatter show all
Defined in:
lib/erlash/formatters/hash_experimental_formatter.rb

Overview

Experimental

Instance Attribute Summary

Attributes inherited from TemplateFormatter

#formatter, #object, #opts, #output

Instance Method Summary collapse

Methods inherited from TemplateFormatter

call, format, #format_elem, #initialize, #safe_call

Constructor Details

This class inherits a constructor from Erlash::TemplateFormatter

Instance Method Details

#experimental_formattingObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/erlash/formatters/hash_experimental_formatter.rb', line 8

def experimental_formatting
  object.each_with_object([]) do |(k, v), s|
    if v.is_a?(Array)
      s << "  - #{k}:"
      s << "#{format_elem(v)}"
    else
      s << "  - #{k}: #{format_elem(v)}"
    end
  end
end

#formatObject



4
5
6
# File 'lib/erlash/formatters/hash_experimental_formatter.rb', line 4

def format
  experimental_formatting
end