hour 0.3.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hour.rb +7 -1
- data/lib/hour/version.rb +1 -1
- 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: b7d9267b3b089937946d971b89f0af4d5562a5ec
|
4
|
+
data.tar.gz: 00d4d94e7769afcb2e127e9d539ccd19decd8bed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98389becbcd5fc96e451d38907e18c5b29c99a235e76593d8ea39e7ddc07351f6917ff06f779f1a08402febeef3d0222290fda8c4a5e6913c1f57ccc8acf7cb9
|
7
|
+
data.tar.gz: 668b7b56bdc3dbc1802c2d29213f729ffa44f5c67ea6217a39b148c51a371f59d48f7a1b0eab52c01dce7059aa7dd03e1d4774c460cc3803d728c2a2ca17e899
|
data/lib/hour.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
module Hour
|
4
4
|
class Hour
|
5
|
-
attr_reader :hours, :minutes, :to_seconds, :days, :hours_less_days, :to_s, :to_formatted_s, :to_a, :to_time, :minutes_in_base10
|
5
|
+
attr_reader :hours, :minutes, :to_seconds, :days, :hours_less_days, :to_s, :to_formatted_s, :to_a, :to_time, :minutes_in_base10, :to_base10
|
6
6
|
|
7
7
|
def initialize(hours, minutes = 0)
|
8
8
|
hours, minutes = hours.split(':') if hours.is_a? String
|
9
9
|
@minutes = [0, minutes.to_i, 59].sort[1] # Constrains assignment to the middle value, w/o the #Clamp method
|
10
10
|
@minutes_in_base10 = @minutes.to_f / 60
|
11
11
|
@to_a = [@hours = hours.to_i, @minutes]
|
12
|
+
@to_base10 = @hours + @minutes_in_base10
|
12
13
|
@to_s = "#{'%02d' % @hours}:#{'%02d' % @minutes}" # Formats single-digits such that '1' will be '01'
|
13
14
|
@to_seconds = (@hours * 60 + @minutes) * 60
|
14
15
|
@days = @hours / 24 || 0
|
@@ -38,6 +39,11 @@ module Hour
|
|
38
39
|
self.new(hour || time_obj.hour, time_obj.min)
|
39
40
|
end
|
40
41
|
|
42
|
+
def self.from_base10(num)
|
43
|
+
hour, minute = num.divmod(1)
|
44
|
+
self.new(hour, minute * 60)
|
45
|
+
end
|
46
|
+
|
41
47
|
alias_method :to_days, :days # DEPRECATION: to_days
|
42
48
|
alias_method :to_hours_less_days, :hours_less_days # DEPRECATION: to_hours_less_days
|
43
49
|
|
data/lib/hour/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- davegregg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|