runby_pace 0.6.112 → 0.6.113
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/distance.rb +9 -3
- data/lib/runby_pace/speed.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863f82385f5fe82d808f93f6eb35019cd214787d
|
4
|
+
data.tar.gz: 264faa8e329286f77b6082e34ddb41eaa12ca527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5a3ec0560b51b42e05a606457c45f47a9d30ab02fca106b83293feddc0fb3d34cfae85b324e5d7ee7961eb3cd53cd414285d9f510676f9d7f20df9bfdadba8
|
7
|
+
data.tar.gz: 3eca9c2755d6dc94a22f8eace340fe867fca958c01d6a3cdedf57df498667d1b46acb8a088b705d09af8c5ff7e68e4a07d76cc082f67c462a41423e97b918dfe
|
data/lib/runby_pace/distance.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Runby
|
2
2
|
# Represents a distance (distance UOM and multiplier)
|
3
3
|
class Distance
|
4
|
+
include Comparable
|
5
|
+
|
4
6
|
attr_reader :uom, :multiplier
|
5
7
|
def initialize(uom = :km, multiplier = 1)
|
6
8
|
case uom
|
@@ -61,9 +63,13 @@ module Runby
|
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
def
|
65
|
-
raise "Cannot compare Runby::Distance to #{other.class}" unless
|
66
|
-
|
66
|
+
def <=>(other)
|
67
|
+
raise "Cannot compare Runby::Distance to #{other.class}" unless [Distance, String].include? other.class
|
68
|
+
if (other.is_a?(String))
|
69
|
+
return 0 if to_s == other.to_s || to_s(format: :long) == other.to_s(format: :long)
|
70
|
+
return self <=> try_parse(other)[:distance]
|
71
|
+
end
|
72
|
+
kilometers <=> other.kilometers
|
67
73
|
end
|
68
74
|
|
69
75
|
private
|
data/lib/runby_pace/speed.rb
CHANGED
@@ -56,12 +56,12 @@ module Runby
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def <=>(other)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
to_s(format: :short) <=> other || to_s(format: :long) <=> other
|
59
|
+
raise "Cannot compare Runby::Speed to #{other.class}" unless [Speed, String].include? other.class
|
60
|
+
if other.is_a? String
|
61
|
+
return 0 if to_s == other.to_s || to_s(format: :long) == other.to_s(format: :long)
|
62
|
+
self <=> try_parse(other)[:speed]
|
64
63
|
end
|
64
|
+
@distance <=> other.distance
|
65
65
|
end
|
66
66
|
|
67
67
|
private
|
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.113
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Walls
|
@@ -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: 989e6cd501d99bece9b7fc8a4e44e569b4d89d3b
|
105
105
|
post_install_message:
|
106
106
|
rdoc_options: []
|
107
107
|
require_paths:
|