remain_timer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/duration_format.rb +8 -14
- data/lib/remain_timer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d0bc3d38b63ce3b3923d86737eaed7f61296b102b5eb4729de54a07ae01274
|
4
|
+
data.tar.gz: baa712ffedfe022772890ee429f6f90c28ffbba37cdf54a1493a0e5e35a3695b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5586a064d99470d80f0b876aa6b8a6ce907c76a93683ea9bbcc4b82d12f2369a252d175a8a14996ca7a3ae7320a39587e32f7a27676b956cac01ea41e665490b
|
7
|
+
data.tar.gz: f3060a14aa86ebb7a8dbd174625a9186bfc993308785dc656bb2c5971fb2a14805e8641db426b8d82a88b9fe3c59392044de959bab4f50ef57cad75209263300
|
data/lib/duration_format.rb
CHANGED
@@ -3,7 +3,12 @@ class DurationFormat
|
|
3
3
|
SECONDS_PER_HOUR = 3600
|
4
4
|
SECONDS_PER_MINUTE = 60
|
5
5
|
PARTS = %i[day hour min sec].freeze
|
6
|
-
PARTS_IN_SECONDS = {
|
6
|
+
PARTS_IN_SECONDS = {
|
7
|
+
sec: 1,
|
8
|
+
min: SECONDS_PER_MINUTE,
|
9
|
+
hour: SECONDS_PER_HOUR,
|
10
|
+
day: SECONDS_PER_DAY,
|
11
|
+
}.freeze
|
7
12
|
|
8
13
|
def self.build_parts(value)
|
9
14
|
parts = {}
|
@@ -23,18 +28,7 @@ class DurationFormat
|
|
23
28
|
|
24
29
|
def self.format(value)
|
25
30
|
parts = build_parts(value)
|
26
|
-
(parts[:day] > 0 ? "#{parts[:day]}day " : "") +
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
class Integer
|
31
|
-
def duration_format
|
32
|
-
DurationFormat.format(self)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Float
|
37
|
-
def duration_format
|
38
|
-
DurationFormat.format(self)
|
31
|
+
(parts[:day] > 0 ? "#{parts[:day]}day " : "") +
|
32
|
+
sprintf('%02d:%02d:%02d', parts[:hour], parts[:min], parts[:sec].round)
|
39
33
|
end
|
40
34
|
end
|
data/lib/remain_timer/version.rb
CHANGED