runby_pace 0.6.114 → 0.6.115

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 466c5700e4c0a990f27205c500ee6838c752d79e
4
- data.tar.gz: 6238b9f490e7d70b922a00f8d9d3fcc92824fa9d
3
+ metadata.gz: d173050371c8c896f1086adc61c56fbba2726439
4
+ data.tar.gz: 77f31225d1de289be644fccf8069a3cb753dfd5c
5
5
  SHA512:
6
- metadata.gz: b435b16123b83dc030788020e7ecd295bcd70fcfd52bfdfa4fc4c0a4db3fd511af58d89d03962dbb6e5824982f1af8c9f9b85046fc6d4bd6df237fbca423c926
7
- data.tar.gz: 190c585deabe76e379dffa602a6d4af6b71b6ebb553e46e4eb4feb2c34d8cf06b3ed8d9b40907690de464eca7a42bae061e86c1dc5e107f82080dfe8c7ede10a
6
+ metadata.gz: 8b4d551333c4c8b82c64ace458239e79395195bdd455b88133f6b4c25d7391b48e993c085bb948df361650981dcad7d424ddb411343aa4216b5efa282601eb0f
7
+ data.tar.gz: c2fff4b74e04ea4c1116d8536dc159e75a80886dc69a4bd3537ae830ca8129513e4a5d50dc8545b14830cadb14525a70f26320e4ced81791bb487735830cbc1c
@@ -29,11 +29,18 @@ module Runby
29
29
  end
30
30
 
31
31
  def as_speed
32
- multiplier = (60 / @time.total_minutes).round(2)
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
- raise 'Comparing paces of different distances is not currently supported' unless @distance == other.distance
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
- return @time.almost_equals?(other_pace, tolerance_time) if other_pace.is_a?(RunbyTime)
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 @time.almost_equals?(other_pace, tolerance_time) if other_pace =~ /^\d\d:\d\d$/
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
- (self - tolerance) <= other_pace && (self + tolerance) >= other_pace
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
@@ -33,7 +33,6 @@ module Runby
33
33
  Runby::Pace.new(time, @distance.uom)
34
34
  end
35
35
 
36
-
37
36
  # @param [String] str is either a long-form speed such as "7.5 miles per hour" or a short-form speed like "7.5mi/ph"
38
37
  def self.parse(str)
39
38
  str = str.to_s.strip.chomp
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.114
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-27 00:00:00.000000000 Z
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: d6e06c6e669965e0c1225bab6f06d671dca85bb4
104
+ commit-hash: 011b197e6b9ba9ff4e2373154596693f370b21ec
105
105
  post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths: