runby_pace 0.6.103 → 0.6.104

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjM2NzE4NDQxZTFjMWM1NDIwM2RhZWU2MmI0OGEzOWEyYzg4NTBiMw==
4
+ ODY0ZWIyNjQ4NmJkMmE1NzIxZWRlNzZkODQ3YWU1ZmZhZDEyNTlmMA==
5
5
  data.tar.gz: !binary |-
6
- OThkMjNmYmQ0NWE5MDQwZTg0ODRkZDcwMWJiNjM2MjM5YzkxMDY2MA==
6
+ M2VjZjM2MjdjNjY2OTZlMDljODkxZjY0ZmM4ZTJlNDMzNmYyY2UyZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWIxYWYwZGU2MmQ3NDMwNGNjNjM3NWNjY2JmNGM1ZWJjYTE4NmRkNGM0YTY5
10
- MDYxNTU5NGFkZDU5YmFjZmJiNWMyZTJiNzk3MzU5OWU3YWIzN2U5YzA5OTc3
11
- YmI1MDQ4MzFjYjUwODk0MmRlYjNiY2RjOWJiYzQ2MDhlMTQzNzM=
9
+ Mjg3YjVkZDk2OWQ2ZjBkYWExNDNmMzJlZGJkMTZjNDlmMjk3ODgxYWIzMDg0
10
+ ZjBjMTkyNGZmNjgzNmUyNTQ3NDgzNDRkOTk2MWExYzc3NmEyYmZiZGJiYWUw
11
+ NDJlMjU3ODRkZDJhNmFlODFmMWY2M2M3M2M3MWFjNjZjYzU5Njk=
12
12
  data.tar.gz: !binary |-
13
- NmJlNTRiY2JmMDA2ZjU1Yjc0YjI3NzQwYjBkZGQ2YzU5YjY0N2NmNmUxYTMz
14
- OTZjODg2YWU1MTM1YWI1M2VjOGY3MDQ5ZDE5YmUzOWM0ZDZjNTQwMDBkODIy
15
- Y2M1YTAxODViNGNjM2IwODAzMGQyZGU0NWY1MjZkZDY0N2Q2NTg=
13
+ NzJhMjNiOTJkZWQ5OTI1NDQ5ZDY2ZjBkY2Q2MDgzMjgwMGYwYjllZGJkMTBj
14
+ MWU1ZTZkM2M5ZmYwYjllZmE1ZDk2ZDliNTJjYTYzMjJiODk0MDVkOGVhOTNi
15
+ OTVhMzlhOTAxZmZjZmRmZTY2MjcyODg5MzNkYTg1OGQxM2UwNmY=
@@ -54,21 +54,13 @@ module Runby
54
54
  end
55
55
 
56
56
  def to_s(format = :long)
57
- formatted_multiplier = format('%g', @multiplier.round(2))
57
+ formatted_multiplier = format('%g', @multiplier.round(2))
58
58
  case format
59
- when :short then "#{formatted_multiplier}#{@uom.to_s(:short)}"
60
- when :long then "#{formatted_multiplier} #{pluralized_uom}"
59
+ when :short then "#{formatted_multiplier}#{@uom.to_s(format)}"
60
+ when :long then "#{formatted_multiplier} #{@uom.to_s(format, plural = (@multiplier > 1))}"
61
61
  end
62
62
  end
63
63
 
64
- def pluralized_uom
65
- uom_description = @uom.description.downcase
66
- if @multiplier > 1
67
- uom_description += 's'
68
- end
69
- uom_description
70
- end
71
-
72
64
  def ==(other)
73
65
  raise "Cannot compare Runby::Distance to #{other.class}" unless other.is_a? Distance
74
66
  @uom == other.uom && @multiplier == other.multiplier
@@ -19,13 +19,17 @@ module Runby
19
19
  @description = @@_uom_definitions[@symbol][:description]
20
20
  end
21
21
 
22
- def to_s(format = :long)
22
+ def to_s(format = :long, pluralize = false)
23
23
  case format
24
24
  when :short then @symbol.to_s
25
- when :long then @description
25
+ when :long then pluralize ? description_plural : @description
26
26
  end
27
27
  end
28
28
 
29
+ def description_plural
30
+ @@_uom_definitions[@symbol][:description_plural]
31
+ end
32
+
29
33
  def self.parse(description)
30
34
  description = description.strip.chomp.downcase
31
35
  found_uom = nil
@@ -65,13 +69,13 @@ module Runby
65
69
  end
66
70
 
67
71
  @@_uom_definitions =
68
- { km: { description: 'Kilometer', conversion_factor: 1.0, synonyms: %w(k km kms kilometer kilometers) },
69
- m: { description: 'Meter', conversion_factor: 0.001, synonyms: %w(m meter meters) },
70
- mi: { description: 'Mile', conversion_factor: 1.609344, synonyms: %w(mi mile miles) },
71
- ft: { description: 'Feet', conversion_factor: 0.0003048, synonyms: %w(ft foot feet) },
72
- yd: { description: 'Yards', conversion_factor: 1093.61, synonyms: %w(y yd yds yard yards) },
72
+ { km: { description: 'kilometer', description_plural: 'kilometers', conversion_factor: 1.0, synonyms: %w(k km kms kilometer kilometers) },
73
+ m: { description: 'meter', description_plural: 'meters', conversion_factor: 0.001, synonyms: %w(m meter meters) },
74
+ mi: { description: 'mile', description_plural: 'miles', conversion_factor: 1.609344, synonyms: %w(mi mile miles) },
75
+ ft: { description: 'foot', description_plural: 'feet', conversion_factor: 0.0003048, synonyms: %w(ft foot feet) },
76
+ yd: { description: 'yard', description_plural: 'yards', conversion_factor: 1093.61, synonyms: %w(y yd yds yard yards) },
73
77
  # Fun distance unit of measures
74
- marathon: { description: 'Marathon', conversion_factor: 42.1648128, synonyms: %w(marathon) }
78
+ marathon: { description: 'marathon', description_plural: 'marathons', conversion_factor: 42.1648128, synonyms: %w(marathon) }
75
79
  }
76
80
  end
77
81
  end
@@ -16,8 +16,8 @@ module Runby
16
16
 
17
17
  def to_s(format = :long)
18
18
  distance_s = @distance.to_s(format)
19
- leading_zero_regex = /^1 ?/
20
- distance_s.gsub!(leading_zero_regex, '')
19
+ leading_one_regex = /^1 ?/
20
+ distance_s.gsub!(leading_one_regex, '')
21
21
  case format
22
22
  when :short then "#{time} p/#{distance_s}"
23
23
  when :long then "#{time} per #{distance_s}"
@@ -22,11 +22,11 @@ module Runby
22
22
  PaceRange.new fast, slow
23
23
  end
24
24
 
25
- def to_s
25
+ def to_s(format = :long)
26
26
  if @fast == @slow
27
- @fast.to_s
27
+ @fast.to_s(format)
28
28
  else
29
- "#{@fast.time}-#{@slow.time} per #{@fast.distance.pluralized_uom}"
29
+ @fast.to_s(format).sub("#{@fast.time}", "#{@fast.time}-#{@slow.time}")
30
30
  end
31
31
  end
32
32
  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.6.103
4
+ version: 0.6.104
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Walls
@@ -100,7 +100,7 @@ homepage: https://github.com/tygerbytes/runby-pace
100
100
  licenses:
101
101
  - MIT
102
102
  metadata:
103
- commit-hash: 02918a2303e0bc6d20230b68c36aba791bd52a0a
103
+ commit-hash: 3b7cb90d7419a84781e23693544fc46f21963b16
104
104
  post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths: