runby_pace 0.4.84 → 0.5.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2NlZWFiMjk5NDdjOTI2OWU1OGIyNjY2MzNhYzhmMzY0MjRlNGIzYg==
4
+ M2Y0Y2I0Zjg3ZjYzZjc4NGNkYjBiN2NmODQwYTYyNTQ3MDkwMTZkNg==
5
5
  data.tar.gz: !binary |-
6
- YjU5MDBjZDMwMTlhOTUyM2JmZTE3YzkzODk3NmY0OTA2MTk5ZDA4Yw==
6
+ ZmE5ZDdkZTgyNTdkOWI3YjVhYjc1NTg0NzE5ZjhhZmJhM2JkOTZiZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWY2YzUzODBhMmExMTJlMjVmZmMzODdlYzZkNWEyNDUyMmQyM2Y0ZmQxM2Fk
10
- M2EwN2M0MGRhZjVmNzM4YmUzYjRmZTU5Zjg0NDc2M2NiMDhjYzM2ZTFjNDVh
11
- ZjYwOWI3ZDQ0OTE1ZTU0NTBhMjExYjAyZGE0MWRmYjJjZWFmYTE=
9
+ NWEwZmIwNjM3YWUzMTNhYmQ1YjcwODdmM2YwODhmMjc3OGI4ZTE4NWRjZDQ1
10
+ ZjZhYWQ0NjJkNTE5NDM4MTg1NDk4MDFjYTViZDMyNjY0ZTcyNmIzYjE5ODVj
11
+ YWZlOTk2NmQxODFmYjI0MWVkNDA2YjA4MmQxNTk5ZGM0NjIyN2Q=
12
12
  data.tar.gz: !binary |-
13
- N2Y4M2QxZDI2YWI1ZjJkNDhhZGE1MGJmZTYzZDgzYzExNzFmMzliODhlMGVj
14
- N2Y3OTAxMDU5ZThmMGYxNGJiNzQxZWNlN2E4YjVjNGY2YTU3ODg5M2UzN2Y2
15
- OTQ1Y2IwMTZjZmI3NzI0NDg3MTdhNmI0YWUxNTllOTYyMGEwNmQ=
13
+ YTZmY2ZhOGUxYTNjZDM1MDY4M2NiZWQyODRjY2I3ODEyMDNhYWMxNWUwMjM5
14
+ ZTk0Mzc4NTNlNzJjNTZiOTA3NGQ2MzA2YTM1MGRlZjI1MTQ1OTU1MGJmZTk5
15
+ NzMzZDU4NTk1MjUzMzM4YzE1NmYzNTBiMDM1YTUxNjQxMDQ5NWE=
@@ -12,7 +12,7 @@ module Runby
12
12
  raise 'Invalid multiplier' unless multiplier.is_a?(Numeric)
13
13
 
14
14
  if distance_uom.is_a? Symbol
15
- raise "Unknown unit of measure #{distance_uom}" unless Runby::PaceUnits.known_uom? distance_uom
15
+ raise "Unknown unit of measure #{distance_uom}" unless Runby::DistanceUnits.known_uom? distance_uom
16
16
  @uom = distance_uom
17
17
  @multiplier = multiplier * 1.0
18
18
  return
@@ -24,7 +24,7 @@ module Runby
24
24
  end
25
25
 
26
26
  def meters
27
- kilometers = @multiplier * Runby::PaceUnits.distance_conversion_factor(@uom)
27
+ kilometers = @multiplier * Runby::DistanceUnits.conversion_factor(@uom)
28
28
  kilometers * 1000.0
29
29
  end
30
30
 
@@ -36,7 +36,7 @@ module Runby
36
36
  # TODO: test V
37
37
  raise "Unable to find distance unit in #{str}" if uom.nil?
38
38
 
39
- parsed_uom = Runby::PaceUnits.parse_unit_of_measure uom
39
+ parsed_uom = Runby::DistanceUnits.parse uom
40
40
  # TODO: test
41
41
  raise "#{uom} is not recognized as a distance unit" if parsed_uom[:uom].nil?
42
42
 
@@ -48,7 +48,7 @@ module Runby
48
48
  end
49
49
 
50
50
  def pluralized_uom
51
- uom_description = PaceUnits.description(@uom).downcase
51
+ uom_description = DistanceUnits.description(@uom).downcase
52
52
  if @multiplier > 1 then
53
53
  uom_description += 's'
54
54
  end
@@ -2,16 +2,16 @@ module Runby
2
2
  # Represents the distance units (e.g. kilometers, miles) used in paces
3
3
  # including the human-readable description of each unit
4
4
  # and the factor used to convert it to kilometers.
5
- class PaceUnits
5
+ class DistanceUnits
6
6
  def self.description(uom)
7
- @@_distance_uom_definition[uom][:description]
7
+ @@_uom_definition[uom][:description]
8
8
  end
9
9
 
10
- def self.parse_unit_of_measure(description)
10
+ def self.parse(description)
11
11
  description = description.strip.chomp
12
12
  found_uom = nil
13
13
  found_uom_factor = 1
14
- @@_distance_uom_definition.each do |uom, details|
14
+ @@_uom_definition.each do |uom, details|
15
15
  if details[:synonyms].include? description
16
16
  if details.has_key? :uom
17
17
  found_uom = details[:uom]
@@ -25,22 +25,22 @@ module Runby
25
25
  { uom: found_uom, factor: found_uom_factor }
26
26
  end
27
27
 
28
- def self.distance_conversion_factor(units)
29
- @@_distance_uom_definition[units][:conversion_factor]
28
+ def self.conversion_factor(units)
29
+ @@_uom_definition[units][:conversion_factor]
30
30
  end
31
31
 
32
32
  def self.known_uom?(symbol)
33
33
  # TODO: test
34
- @@_distance_uom_definition.has_key?(symbol)
34
+ @@_uom_definition.has_key?(symbol)
35
35
  end
36
36
 
37
- @@_distance_uom_definition =
37
+ @@_uom_definition =
38
38
  { km: { description: 'Kilometer', conversion_factor: 1.0, synonyms: %w(k km kms kilometer kilometers) },
39
39
  m: { description: 'Meter', conversion_factor: 0.001, synonyms: %w(m meter meters) },
40
40
  mi: { description: 'Mile', conversion_factor: 1.609344, synonyms: %w(mi mile miles) },
41
41
  ft: { description: 'Feet', conversion_factor: 0.0003048, synonyms: %w(ft foot feet) },
42
42
  # Special UOMs, which just point to "real" UOMs in this hash table
43
- marathon: { description: 'Marathon', uom: :mi, factor: 26.2, synonyms: %w(marathon), uom: :mi, factor: 26.2 }
43
+ marathon: { description: 'Marathon', synonyms: %w(marathon), uom: :mi, factor: 26.2 }
44
44
  }
45
45
  end
46
46
  end
@@ -41,7 +41,7 @@ module Runby
41
41
  five_k_time = Runby::RunbyTime.new(five_k_time)
42
42
  x2 = ((five_k_time.total_minutes * 2) - (MIDPOINT_X - 1)) - 1
43
43
  minutes_per_km = slope * x2 + @fastest_pace_km.total_minutes + curve_minutes(x2)
44
- minutes_per_unit = minutes_per_km * Runby::PaceUnits.distance_conversion_factor(distance_units)
44
+ minutes_per_unit = minutes_per_km * Runby::DistanceUnits.conversion_factor(distance_units)
45
45
  Runby::RunbyTime.from_minutes(minutes_per_unit)
46
46
  end
47
47
 
@@ -1,3 +1,3 @@
1
1
  module Runby
2
- VERSION = "0.4.#{`git rev-list --count HEAD`}".freeze
2
+ VERSION = "0.5.#{`git rev-list --count HEAD`}".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runby_pace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.84
4
+ version: 0.5.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Walls
@@ -74,10 +74,10 @@ files:
74
74
  - bin/setup
75
75
  - lib/runby_pace.rb
76
76
  - lib/runby_pace/distance.rb
77
+ - lib/runby_pace/distance_units.rb
77
78
  - lib/runby_pace/pace.rb
78
79
  - lib/runby_pace/pace_data.rb
79
80
  - lib/runby_pace/pace_range.rb
80
- - lib/runby_pace/pace_units.rb
81
81
  - lib/runby_pace/run_math.rb
82
82
  - lib/runby_pace/run_type.rb
83
83
  - lib/runby_pace/run_types/all_run_types.g.rb
@@ -99,7 +99,7 @@ homepage: https://github.com/tygerbytes/runby-pace
99
99
  licenses:
100
100
  - MIT
101
101
  metadata:
102
- commit-hash: 6d6a0922c203bcbe7e3e131623a70aea292fe071
102
+ commit-hash: b7e91031243d197b78a140542c04b9089c35f47c
103
103
  post_install_message:
104
104
  rdoc_options: []
105
105
  require_paths: