Module: Formatter

Defined in:
lib/localio/formatter.rb

Class Method Summary collapse

Class Method Details

.format(key, formatter, callback) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/localio/formatter.rb', line 4

def self.format(key, formatter, callback)
  case formatter
    when :smart
      # Smart formatting is given by the processor.
      # I don't like this very much but creating more classes seemed overkill.
      callback.call(key)
    when :none
      key
    when :camel_case
      key.space_to_underscore.strip_tag.camel_case
    when :snake_case
      key.space_to_underscore.strip_tag.downcase
    else
      raise ArgumentError, 'Unknown formatting used. Must use :smart, :none, :camel_case or :snake_case'
  end
end