hour-ruby 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hour.rb +15 -0
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b8bac3638cd0e4086e0929f7fc05aae9d6e165495dc9427a2a02a587f1b1f20
4
- data.tar.gz: 2afec0e7ad09044471bf724c2d09070a3d251c7eb676538484f4f62ec3d29b8d
3
+ metadata.gz: fc01dd18ded1207c7b8983eb21f9ef335318760adfc8629ac21231666015b4d0
4
+ data.tar.gz: 1d992b5f668e305cbf50f26142c1ea52d1183ca459686ff6c2d2c426497d52ae
5
5
  SHA512:
6
- metadata.gz: 61261cd9e0c2e96aaa73b97f3429ed99c2a3a6880f6e9e7a32efba3fb22b8f517c4b3b3f3e6f2c5e05a52061063e213872366c2cb9ded37329d9c83cd1383f86
7
- data.tar.gz: e242de3802e2e9b424968617b49900d280e0e95d18b002cf48c87551c42e1931ef70522753693afe94783ac0fae0991bc773e9bc8778cc838862b944c5d55fed
6
+ metadata.gz: e19b77cd897cbf3800e87d92ff3d67c8bb796aa0e52abf37f3d272b893ef00d13e7137a9738589cd4a5c60147850a17b96aa5e99137e7ed3d70a49d2bcce0f84
7
+ data.tar.gz: f661487e9153b7d90c8e6380f447bd1f8c42088010cc8f2a51be58bfa0881a393443609e46883f34be9a655b82a67f2ba219c573633014aa0c390755dc6bdd43
data/lib/hour.rb CHANGED
@@ -144,6 +144,21 @@ class Hour
144
144
  self.class.new(hours, minutes, seconds)
145
145
  end
146
146
 
147
+ def -(other)
148
+ hours = @h - other.h - (@m - other.m - ((@s - other.s) / 60)) / 60
149
+ minutes = (@m - other.m - ((@s - other.s) / 60)) % 60
150
+
151
+ if @s && other.s
152
+ seconds = (@s - other.s) % 60
153
+ elsif (!@s) && (!other.s)
154
+ seconds = false
155
+ else
156
+ raise "TODO: how to resolve this?"
157
+ end
158
+
159
+ self.class.new(hours, minutes, seconds)
160
+ end
161
+
147
162
  # Returns a decorator providing convenience methods for working with hours.
148
163
  #
149
164
  # Hour.new(1, 25).hours.round # => 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hour-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James C Russell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2019-07-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "."
14
14
  email: james@101ideas.cz
@@ -39,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 2.7.6
42
+ rubygems_version: 3.0.3
44
43
  signing_key:
45
44
  specification_version: 4
46
45
  summary: ''