read_time 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/read_time/version.rb +1 -1
- data/lib/read_time.rb +47 -47
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1298acc849510b25978ba14dcb3b11e9002c8c93
|
4
|
+
data.tar.gz: 4dc925d3a4b4071ba4b063e57f35606cf90b6977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cda20886fe0abf1ea2b0ea45ede2d702d6a5a4ee33d4d0aab699362957d3bfec0ffac71fec8761aa9153e001d97abe32ec9954fdf3795bec8b9b7c97bb3280a
|
7
|
+
data.tar.gz: 4a87d17076fe0d4fec5a27f9054358738a49f9d16f6b6ed02d0e19d950b035c9bbe5cd8331e19b4b19eace62d1cfc41b990ef06baa3b88cf2ae2778dee4f9e7f
|
data/lib/read_time/version.rb
CHANGED
data/lib/read_time.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
1
|
require "read_time/version"
|
2
2
|
|
3
3
|
module ReadTime
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
4
|
+
module String
|
5
|
+
@@output = ""
|
6
|
+
|
7
|
+
def seconds_to_read
|
8
|
+
(self.split(" ").count/3.3333333333).to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def minutes_to_read(secs)
|
12
|
+
if secs / 60 > 1
|
13
|
+
@@output << "#{secs / 60} minutes "
|
14
|
+
else
|
15
|
+
@@output << "1 minute "
|
16
|
+
end
|
17
|
+
|
18
|
+
if secs % 60 > 0
|
19
|
+
@@output << "#{secs % 60} seconds"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def hours_to_read(secs)
|
24
|
+
if secs / 3600 > 1
|
25
|
+
@@output << "#{secs / 3600} hours "
|
26
|
+
else
|
27
|
+
@@output << "1 hour "
|
28
|
+
end
|
29
|
+
|
30
|
+
if secs % 3600 > 0
|
31
|
+
minutes_to_read(secs % 3600)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def time_to_read
|
36
|
+
if seconds_to_read <= 1
|
37
|
+
puts "1 second"
|
38
|
+
elsif seconds_to_read > 1 && seconds_to_read < 60
|
39
|
+
puts "#{seconds_to_read} seconds"
|
40
|
+
else
|
41
|
+
if seconds_to_read > 3600
|
42
|
+
hours_to_read(seconds_to_read)
|
43
|
+
else
|
44
|
+
minutes_to_read(seconds_to_read)
|
45
|
+
end
|
46
|
+
puts @@output
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
50
|
end
|
51
51
|
|
52
52
|
class String
|
53
|
-
|
53
|
+
include ReadTime::String
|
54
54
|
end
|