runby_pace 0.6.114 → 0.6.115
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 +4 -4
- data/lib/runby_pace/pace.rb +16 -6
- data/lib/runby_pace/speed.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d173050371c8c896f1086adc61c56fbba2726439
|
|
4
|
+
data.tar.gz: 77f31225d1de289be644fccf8069a3cb753dfd5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b4d551333c4c8b82c64ace458239e79395195bdd455b88133f6b4c25d7391b48e993c085bb948df361650981dcad7d424ddb411343aa4216b5efa282601eb0f
|
|
7
|
+
data.tar.gz: c2fff4b74e04ea4c1116d8536dc159e75a80886dc69a4bd3537ae830ca8129513e4a5d50dc8545b14830cadb14525a70f26320e4ced81791bb487735830cbc1c
|
data/lib/runby_pace/pace.rb
CHANGED
|
@@ -29,11 +29,18 @@ module Runby
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def as_speed
|
|
32
|
-
|
|
32
|
+
total_minutes = @time.total_minutes
|
|
33
|
+
multiplier = total_minutes > 0 ? (60 / total_minutes).round(2) : 0
|
|
33
34
|
distance = Runby::Distance.new(@distance.uom, multiplier)
|
|
34
35
|
Runby::Speed.new distance
|
|
35
36
|
end
|
|
36
37
|
|
|
38
|
+
def meters_per_minute
|
|
39
|
+
total_minutes = @time.total_minutes
|
|
40
|
+
return 0 unless total_minutes > 0
|
|
41
|
+
@distance.meters / total_minutes
|
|
42
|
+
end
|
|
43
|
+
|
|
37
44
|
# @param [String] str is either a long-form pace such as "10:00 per mile" or a short-form pace like "10:00 p/mi"
|
|
38
45
|
def self.parse(str)
|
|
39
46
|
str = str.to_s.strip.chomp
|
|
@@ -58,8 +65,7 @@ module Runby
|
|
|
58
65
|
|
|
59
66
|
def <=>(other)
|
|
60
67
|
if other.is_a? Pace
|
|
61
|
-
|
|
62
|
-
@time <=> other.time
|
|
68
|
+
(meters_per_minute.round(2)) <=> (other.meters_per_minute.round(2))
|
|
63
69
|
elsif other.is_a? RunbyTime
|
|
64
70
|
@time <=> other.time
|
|
65
71
|
elsif other.is_a? String
|
|
@@ -70,13 +76,17 @@ module Runby
|
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
def almost_equals?(other_pace, tolerance_time = '00:01')
|
|
73
|
-
|
|
79
|
+
if other_pace.is_a?(RunbyTime)
|
|
80
|
+
return almost_equals?(Pace.new(other_pace, @distance), tolerance_time)
|
|
81
|
+
end
|
|
74
82
|
if other_pace.is_a?(String)
|
|
75
|
-
return
|
|
83
|
+
return almost_equals?(Pace.new(other_pace, @distance), tolerance_time) if other_pace =~ /^\d?\d:\d\d$/
|
|
76
84
|
other_pace = Pace.parse(other_pace)
|
|
77
85
|
end
|
|
78
86
|
tolerance = RunbyTime.new(tolerance_time)
|
|
79
|
-
|
|
87
|
+
fast_end = (self - tolerance)
|
|
88
|
+
slow_end = (self + tolerance)
|
|
89
|
+
slow_end <= other_pace && other_pace <= fast_end
|
|
80
90
|
end
|
|
81
91
|
|
|
82
92
|
# @param [Pace, RunbyTime] other
|
data/lib/runby_pace/speed.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.115
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ty Walls
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-11-
|
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -101,7 +101,7 @@ homepage: https://github.com/tygerbytes/runby-pace
|
|
|
101
101
|
licenses:
|
|
102
102
|
- MIT
|
|
103
103
|
metadata:
|
|
104
|
-
commit-hash:
|
|
104
|
+
commit-hash: 011b197e6b9ba9ff4e2373154596693f370b21ec
|
|
105
105
|
post_install_message:
|
|
106
106
|
rdoc_options: []
|
|
107
107
|
require_paths:
|