lib/runby_pace/distance.rb in runby_pace-0.6.140 vs lib/runby_pace/distance.rb in runby_pace-0.6.141
- old
+ new
@@ -4,20 +4,20 @@
include Comparable
attr_reader :uom, :multiplier
def initialize(uom = :km, multiplier = 1)
case uom
- when Distance
- return init_from_clone uom
- when DistanceUnit
- return init_from_distance_unit uom, multiplier
- when String
- return init_from_string uom
- when Symbol
- return init_from_symbol uom, multiplier
- else
- raise 'Invalid distance unit of measure'
+ when Distance
+ return init_from_clone uom
+ when DistanceUnit
+ return init_from_distance_unit uom, multiplier
+ when String
+ return init_from_string uom
+ when Symbol
+ return init_from_symbol uom, multiplier
+ else
+ raise 'Invalid distance unit of measure'
end
end
def convert_to(target_uom)
target_uom = DistanceUnit.new target_uom unless target_uom.is_a?(DistanceUnit)
@@ -58,11 +58,11 @@
end
def to_s(format: :short)
formatted_multiplier = format('%g', @multiplier.round(2))
case format
- when :short then "#{formatted_multiplier} #{@uom.to_s(format: format)}"
- when :long then "#{formatted_multiplier} #{@uom.to_s(format: format, pluralize: (@multiplier > 1))}"
+ when :short then "#{formatted_multiplier} #{@uom.to_s(format: format)}"
+ when :long then "#{formatted_multiplier} #{@uom.to_s(format: format, pluralize: (@multiplier > 1))}"
end
end
# @param [Distance, String] other
def <=>(other)