Class: Height::Formatters::Imperial

Inherits:
Base
  • Object
show all
Defined in:
lib/height/formatters/imperial.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Height::Formatters::Base

Instance Method Details

#format(format = :default) ⇒ Object



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

def format(format = :default)
  feet = @value.to_feet

  result = "#{feet.feet} ft #{feet.inches} in"
  if Object.const_defined?(:I18n)
    ::I18n.t :"height.format.imperial.#{format}", {
      feet: feet.feet,
      inches: feet.inches,
      only_feet: feet,
      only_inches: feet.to_inches,
      default: result
    }
  else
    result
  end
end