Class: Height::Formatters::Metric
- Defined in:
- lib/height/formatters/metric.rb
Instance Method Summary collapse
Methods inherited from Base
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 20 |
# File 'lib/height/formatters/metric.rb', line 4 def format(format = :default) meters = @value.to_meters result = "#{meters.meters}m #{meters.centimeters}cm" if Object.const_defined?(:I18n) ::I18n.t :"height.format.metric.#{format}", { meters: meters.meters, centimeters: meters.centimeters, only_meters: meters, only_centimeters: meters.to_centimeters, default: result } else result end end |