Module: Converter
- Included in:
- Calcpace
- Defined in:
- lib/calcpace/converter.rb
Instance Method Summary collapse
-
#convert(distance, unit) ⇒ Object
tem que chamar as checagens de digitos antes de chamar o convert_distance.
- #convert_to_clocktime(seconds) ⇒ Object
- #convert_to_seconds(time) ⇒ Object
Instance Method Details
#convert(distance, unit) ⇒ Object
tem que chamar as checagens de digitos antes de chamar o convert_distance
14 15 16 17 18 19 20 21 |
# File 'lib/calcpace/converter.rb', line 14 def convert(distance, unit) case unit when 'km' (distance * 0.621371).round(2) when 'mi' (distance * 1.60934).round(2) end end |
#convert_to_clocktime(seconds) ⇒ Object
9 10 11 |
# File 'lib/calcpace/converter.rb', line 9 def convert_to_clocktime(seconds) Time.at(seconds).utc.strftime('%H:%M:%S') end |
#convert_to_seconds(time) ⇒ Object
4 5 6 7 |
# File 'lib/calcpace/converter.rb', line 4 def convert_to_seconds(time) hour, minute, seconds = time.split(':').map(&:to_i) (hour * 3600) + (minute * 60) + seconds end |