read_time 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b033617b791dc51f8ec5d8fcbfc92f4a5f89f0d
4
- data.tar.gz: '05543138ecd6bf0129202e30f3b44a9528a4d862'
3
+ metadata.gz: 909226666ae44846ae012533efb86f41f45a45de
4
+ data.tar.gz: 0c36872dbae3e78978beca8fbcb1a4babc934d2b
5
5
  SHA512:
6
- metadata.gz: 561d56e56f586ccca4d31d066533293e7c2ee6e29421f49be7ec167a3d592a06c6e43cbac5845a89901968f9889c3cd2b02c09ffa2855ed10ebbfe0ddc9e5ee5
7
- data.tar.gz: d374b9e99357660821c3c64300555868e9ce718bf9332bcafff86c769a62a39f08c29fa76dc3f33eb7fad0d017a7852bef75c33a524adbe3c495980afee0717b
6
+ metadata.gz: 8ac6cb0ba3b8ba040e7405a95dcddb7213cd52dbf5c2e40eaf2057687845ad68e9fc228c2345b3aade3c3da1f34d010b2931199ab1f62f9702bad6f93036b215
7
+ data.tar.gz: 6a10a1bdf33d5b8b4cd10715796adcfe006b28db142904a85e0db7812b3ce758f35654dcc31fe5c5b14fdaa8f1b9825feeb8fe55fb2f3b42cb64cb6e175044ce
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- To use the gem, call `time_to_read` on string.
23
+ To use the gem; add `require 'read_time'` to your script file and call `time_to_read` on string.
24
24
 
25
25
  Example:
26
26
  `some_string.time_to_read`
data/lib/read_time.rb CHANGED
@@ -1,54 +1,58 @@
1
1
  require "read_time/version"
2
2
 
3
3
  module ReadTime
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
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
+ if secs % 60 > 1
20
+ @@output << "#{secs % 60} seconds"
21
+ else
22
+ @@output << "1 second"
23
+ end
24
+ end
25
+ end
26
+
27
+ def hours_to_read(secs)
28
+ if secs / 3600 > 1
29
+ @@output << "#{secs / 3600} hours "
30
+ else
31
+ @@output << "1 hour "
32
+ end
33
+
34
+ if secs % 3600 > 0
35
+ minutes_to_read(secs % 3600)
36
+ end
37
+ end
38
+
39
+ def time_to_read
40
+ if seconds_to_read <= 1
41
+ puts "1 second"
42
+ elsif seconds_to_read > 1 && seconds_to_read < 60
43
+ puts "#{seconds_to_read} seconds"
44
+ else
45
+ if seconds_to_read > 3600
46
+ hours_to_read(seconds_to_read)
47
+ else
48
+ minutes_to_read(seconds_to_read)
49
+ end
50
+ puts @@output
51
+ end
52
+ end
53
+ end
50
54
  end
51
55
 
52
56
  class String
53
- include ReadTime::String
57
+ include ReadTime::String
54
58
  end
@@ -1,3 +1,3 @@
1
1
  module ReadTime
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: read_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaan Kölköy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-22 00:00:00.000000000 Z
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler