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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6a23578f0080013d11088d8942eef4aeb20e808
4
- data.tar.gz: 979e8d31b0ae9e4cfa1eda173fd6eab73978409b
3
+ metadata.gz: 863f82385f5fe82d808f93f6eb35019cd214787d
4
+ data.tar.gz: 264faa8e329286f77b6082e34ddb41eaa12ca527
5
5
  SHA512:
6
- metadata.gz: 601aaaeb48f9fef5d97ee5edcc62f44cb2c9aa734d67b94d91ada0f0635e03aaafb0bf0b845a70898762595e60ebdcaad3eb6fee286dcaa13dbb0a831d49689a
7
- data.tar.gz: b86423d35963e49e384f5de4b193118f662776f7074dca439c936c8cd85c8fc5d7c6e297148b7efbacafc0f9d725cd7ad8126b4a802f9a6460b9f8e0e25cb308
6
+ metadata.gz: 5d5a3ec0560b51b42e05a606457c45f47a9d30ab02fca106b83293feddc0fb3d34cfae85b324e5d7ee7961eb3cd53cd414285d9f510676f9d7f20df9bfdadba8
7
+ data.tar.gz: 3eca9c2755d6dc94a22f8eace340fe867fca958c01d6a3cdedf57df498667d1b46acb8a088b705d09af8c5ff7e68e4a07d76cc082f67c462a41423e97b918dfe
@@ -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 ==(other)
65
- raise "Cannot compare Runby::Distance to #{other.class}" unless other.is_a? Distance
66
- @uom == other.uom && @multiplier == other.multiplier
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
@@ -56,12 +56,12 @@ module Runby
56
56
  end
57
57
 
58
58
  def <=>(other)
59
- if other.is_a? Speed
60
- @distance <=> other.distance
61
- elsif other.is_a? String
62
- # TODO: Parse as Speed when Speed.parse is available
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.112
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: fa51fc21a20b69ad77f48a217732e0294fe0218e
104
+ commit-hash: 989e6cd501d99bece9b7fc8a4e44e569b4d89d3b
105
105
  post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths: