makit 0.0.37 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/makit/humanize.rb +23 -6
- data/lib/makit/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: c27f269da0b90889675df5626377f39ea4041da3fd699c55b38cb11765b8f25c
|
4
|
+
data.tar.gz: 0c38c29372bc46db6fe59fc71791d2ade93a324cb79e7b104b2070ff8e69e326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 457c42044259e99d39778189f620bc631b9326f4e85fd632420bb906fd714f9af5caf883492a007f19085fc8d517882ff26aabe2e7ba130eaa79296caed1608d
|
7
|
+
data.tar.gz: 6dc2f0740d5516062053aa379f039a48bfa02fc44ec2b0f53ab4d2ca16fa01346e56f25bb87cfb96c3eb7fc017b089e0356fce2eb137f7d18d9dc36504b12fce
|
data/lib/makit/humanize.rb
CHANGED
@@ -91,21 +91,38 @@ module Makit
|
|
91
91
|
"#{hours}h #{minutes}m #{seconds}s"
|
92
92
|
end
|
93
93
|
|
94
|
-
def self.get_humanized_duration(
|
95
|
-
minutes = (
|
96
|
-
seconds = (
|
94
|
+
def self.get_humanized_duration(seconds_value)
|
95
|
+
minutes = (seconds_value / 60).to_i
|
96
|
+
seconds = (seconds_value % 60).to_i
|
97
97
|
hours = (minutes / 60).to_i
|
98
98
|
minutes = minutes % 60
|
99
99
|
days = (hours / 24).to_i
|
100
100
|
hours = hours % 24
|
101
|
-
milliseconds = (
|
101
|
+
milliseconds = (seconds_value % 1 * 1000).to_i
|
102
102
|
|
103
103
|
parts = []
|
104
104
|
parts << "#{days} days" if days > 0
|
105
105
|
parts << "#{hours} hours" if hours > 0
|
106
|
-
|
107
|
-
|
106
|
+
if(minutes > 0)
|
107
|
+
if(minutes == 1)
|
108
|
+
parts << "1 minute"
|
109
|
+
else
|
110
|
+
parts << "#{minutes} minutes"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if(seconds > 0)
|
114
|
+
if(seconds == 1)
|
115
|
+
parts << "1 second"
|
116
|
+
else
|
117
|
+
parts << "#{seconds} seconds"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
#parts << "#{seconds} seconds" if seconds > 0
|
108
121
|
parts << "#{milliseconds} milliseconds" if milliseconds > 0 && seconds < 1
|
122
|
+
|
123
|
+
if(parts.length == 0)
|
124
|
+
parts << "0 seconds"
|
125
|
+
end
|
109
126
|
parts.join(", ")
|
110
127
|
end
|
111
128
|
end
|
data/lib/makit/version.rb
CHANGED