refined-refinements 0.0.2.2 → 0.0.2.3

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
  SHA256:
3
- metadata.gz: 24817b1d2cceaa5a81ffe45fa2854a76573144cca65f61e6a1ab1b673e32bcb8
4
- data.tar.gz: 897d02ac393760295973a82aeccb98de4cf634b802876eb7a38669dae00ec245
3
+ metadata.gz: 4fc3be8d68c3052ffea8311e45bdef17c25b333e4ae3128f089fb6c6e862a7d5
4
+ data.tar.gz: a83193ae99ad5ef2e719d1d0524b920ee0942d81ddea3959e582a3a5404788a4
5
5
  SHA512:
6
- metadata.gz: 073e450489a4adba21d7520979db357645f2a07e69744f257cbb528f5e83164920b835f2ca889941536cbee48301d2f50b862aa3fe22334c28f56309f9861cfd
7
- data.tar.gz: a56cb8671cdcd2218c7f03461671682341448afbfeca81d709b0a425e1225cfc31f5103a69a51d1fcc1e02f1f305c3b603f98e382ba52bfc52c40c678be58ccd
6
+ metadata.gz: 266f550bb3c5878534eb31593c18d1bbe5c0b1dbdf95812a595cc26f100bbe0e7b6cf2f4b1e8b2e34e1aca8e1ad3aa3cc3caea9f8cfedaa6891a60d1f202b3e3
7
+ data.tar.gz: '084a6326193a094fdd57f92d2f27430f8a08dd489d9a6401ba49967fa16a7f8555a3a3052daab4bcd30009e3123b9401009e037318fd9704b87d27d3f898059b'
@@ -5,7 +5,7 @@ class Hour
5
5
  end
6
6
 
7
7
  def self.now
8
- self.from(Time.now)
8
+ self.from_time(Time.now)
9
9
  end
10
10
 
11
11
  def self.from_time(time)
@@ -13,7 +13,22 @@ class Hour
13
13
  end
14
14
 
15
15
  attr_reader :minutes
16
- def initialize(hours, minutes = 0)
16
+ def initialize(*args)
17
+ if args.length == 1 && args.first.is_a?(Hash)
18
+ self.initialize_from_keyword_args(**args.first)
19
+ else
20
+ self.initialize_legacy(*args)
21
+ end
22
+ end
23
+
24
+ def initialize_legacy(hours, minutes = 0)
25
+ @minutes = (hours * 60) + minutes
26
+ end
27
+
28
+ # TODO: parse 0:1:20
29
+ # TODO: format 1:30 / 90min
30
+ # TODO: hr: 1, min: 20, sec: false to disable sec or sth like that.
31
+ def initialize_from_keyword_args(hr: 0, min: 0, sec: 0)
17
32
  @minutes = (hours * 60) + minutes
18
33
  end
19
34
 
@@ -32,6 +47,10 @@ class Hour
32
47
  end
33
48
  end
34
49
 
50
+ def /(ratio)
51
+ self.class.new(0, self.minutes / ratio)
52
+ end
53
+
35
54
  def hours
36
55
  if (@minutes / 60).round > (@minutes / 60)
37
56
  (@minutes / 60).round - 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refined-refinements
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.2
4
+ version: 0.0.2.3
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-01-23 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "."
14
14
  email: james@101ideas.cz
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  version: '0'
51
51
  requirements: []
52
52
  rubyforge_project:
53
- rubygems_version: 2.7.4
53
+ rubygems_version: 2.7.6
54
54
  signing_key:
55
55
  specification_version: 4
56
56
  summary: ''