Module: Joule::UnitsConversion

Included in:
CSV::Parser
Defined in:
lib/joule/units_conversion.rb

Instance Method Summary collapse

Instance Method Details

#convert_distance(distance) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/joule/units_conversion.rb', line 12

def convert_distance(distance)
  #convert distance to mm
  if @workout.properties.distance_units_are_english?
    miles_to_millimeters distance
  else
    kilometers_to_millimeters distance
  end
end

#convert_speed(speed) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/joule/units_conversion.rb', line 3

def convert_speed(speed)
  #convert to mm/s
  if @workout.properties.speed_units_are_english?
    miles_per_hour_to_millimeters_per_second speed
  else
    kilometers_per_hour_to_millimeters_per_second speed
  end
end

#kilometers_per_hour_to_millimeters_per_second(speed) ⇒ Object



29
30
31
# File 'lib/joule/units_conversion.rb', line 29

def kilometers_per_hour_to_millimeters_per_second(speed)
  speed * 277.78 
end

#kilometers_to_millimeters(distance) ⇒ Object



45
46
47
# File 'lib/joule/units_conversion.rb', line 45

def kilometers_to_millimeters(distance)
  distance * 1000000
end

#miles_per_hour_to_millimeters_per_second(speed) ⇒ Object



21
22
23
# File 'lib/joule/units_conversion.rb', line 21

def miles_per_hour_to_millimeters_per_second(speed)
  speed * 447.04 
end

#miles_to_millimeters(distance) ⇒ Object



37
38
39
# File 'lib/joule/units_conversion.rb', line 37

def miles_to_millimeters(distance)
  distance * 1609344
end

#millimeters_per_second_to_kilometers_per_hour(speed) ⇒ Object



33
34
35
# File 'lib/joule/units_conversion.rb', line 33

def millimeters_per_second_to_kilometers_per_hour(speed)
  speed / 277.78 
end

#millimeters_per_second_to_miles_per_hour(speed) ⇒ Object



25
26
27
# File 'lib/joule/units_conversion.rb', line 25

def millimeters_per_second_to_miles_per_hour(speed)
  speed / 447.04 
end

#millimeters_to_kilometers(distance) ⇒ Object



49
50
51
# File 'lib/joule/units_conversion.rb', line 49

def millimeters_to_kilometers(distance)
  distance / 1000000
end

#millimeters_to_miles(distance) ⇒ Object



41
42
43
# File 'lib/joule/units_conversion.rb', line 41

def millimeters_to_miles(distance)
  distance / 1609344
end