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 +8 -8
- data/lib/runby_pace/distance.rb +3 -11
- data/lib/runby_pace/distance_unit.rb +12 -8
- data/lib/runby_pace/pace.rb +2 -2
- data/lib/runby_pace/pace_range.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODY0ZWIyNjQ4NmJkMmE1NzIxZWRlNzZkODQ3YWU1ZmZhZDEyNTlmMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2VjZjM2MjdjNjY2OTZlMDljODkxZjY0ZmM4ZTJlNDMzNmYyY2UyZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mjg3YjVkZDk2OWQ2ZjBkYWExNDNmMzJlZGJkMTZjNDlmMjk3ODgxYWIzMDg0
|
10
|
+
ZjBjMTkyNGZmNjgzNmUyNTQ3NDgzNDRkOTk2MWExYzc3NmEyYmZiZGJiYWUw
|
11
|
+
NDJlMjU3ODRkZDJhNmFlODFmMWY2M2M3M2M3MWFjNjZjYzU5Njk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzJhMjNiOTJkZWQ5OTI1NDQ5ZDY2ZjBkY2Q2MDgzMjgwMGYwYjllZGJkMTBj
|
14
|
+
MWU1ZTZkM2M5ZmYwYjllZmE1ZDk2ZDliNTJjYTYzMjJiODk0MDVkOGVhOTNi
|
15
|
+
OTVhMzlhOTAxZmZjZmRmZTY2MjcyODg5MzNkYTg1OGQxM2UwNmY=
|
data/lib/runby_pace/distance.rb
CHANGED
@@ -54,21 +54,13 @@ module Runby
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def to_s(format = :long)
|
57
|
-
|
57
|
+
formatted_multiplier = format('%g', @multiplier.round(2))
|
58
58
|
case format
|
59
|
-
when :short then "#{formatted_multiplier}#{@uom.to_s(
|
60
|
-
when :long then "#{formatted_multiplier} #{
|
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: '
|
69
|
-
m: { description: '
|
70
|
-
mi: { description: '
|
71
|
-
ft: { description: '
|
72
|
-
yd: { description: '
|
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: '
|
78
|
+
marathon: { description: 'marathon', description_plural: 'marathons', conversion_factor: 42.1648128, synonyms: %w(marathon) }
|
75
79
|
}
|
76
80
|
end
|
77
81
|
end
|
data/lib/runby_pace/pace.rb
CHANGED
@@ -16,8 +16,8 @@ module Runby
|
|
16
16
|
|
17
17
|
def to_s(format = :long)
|
18
18
|
distance_s = @distance.to_s(format)
|
19
|
-
|
20
|
-
distance_s.gsub!(
|
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}
|
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.
|
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:
|
103
|
+
commit-hash: 3b7cb90d7419a84781e23693544fc46f21963b16
|
104
104
|
post_install_message:
|
105
105
|
rdoc_options: []
|
106
106
|
require_paths:
|