time_to_read 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/time_to_read.rb +2 -2
- data/lib/time_to_read/version.rb +1 -1
- data/spec/time_to_read_spec.rb +10 -10
- 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: f25405ea085606f125438d9979bbd64ec0c1cb83
|
4
|
+
data.tar.gz: dd2d6f19f9eff4a25ac47ef87f9c4c23bd3c3c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be371607b49fb1e5173723ae37391f02a9656970813ef3d1cb3a02906334a45320b73ac606398240290ab08016c1b72475d486bb48525c4594d08236ac7430e9
|
7
|
+
data.tar.gz: 964391bd3167604df6387dcf6624c0426584d0ae1fdd1a64518d8f18c3e86bd2ba8175f957dc9ae4fd0994f0948945f079da472ef6f9114d0641b53bf00bb09e
|
data/lib/time_to_read.rb
CHANGED
@@ -8,10 +8,10 @@ module TimeToRead
|
|
8
8
|
if time >= 60
|
9
9
|
hours = read_time_hours(time).to_s
|
10
10
|
minutes = read_time_minutes(time - hours.to_i * 60).to_s
|
11
|
-
answer = hours + minutes
|
11
|
+
answer = '~' + hours + minutes
|
12
12
|
elsif time < 60 && time > 1
|
13
13
|
minutes = read_time_minutes(time).to_s
|
14
|
-
answer = minutes
|
14
|
+
answer = '~' + minutes
|
15
15
|
else
|
16
16
|
answer = 'Less than a minute'
|
17
17
|
end
|
data/lib/time_to_read/version.rb
CHANGED
data/spec/time_to_read_spec.rb
CHANGED
@@ -5,29 +5,29 @@ describe "TimeToRead" do
|
|
5
5
|
describe "time_to_read" do
|
6
6
|
it "returns the reading time in phrase form when there is an even number of minutes" do
|
7
7
|
text = "word " * 500
|
8
|
-
expect(text.time_to_read(250)).to eql "2 minutes"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "returns the reading time in phrase form when there are seconds" do
|
12
|
-
text = "word " * 625
|
13
|
-
expect(text.time_to_read(250)).to eql "2 minutes"
|
8
|
+
expect(text.time_to_read(250)).to eql "~ 2 minutes"
|
14
9
|
end
|
15
10
|
|
16
11
|
it "returns the reading time in phrase form when read time is an hour" do
|
17
12
|
text = "word " * 15000
|
18
|
-
expect(text.time_to_read(250)).to eql "1 hour"
|
13
|
+
expect(text.time_to_read(250)).to eql "~ 1 hour"
|
19
14
|
end
|
20
15
|
|
21
|
-
it "returns the reading time in phrase form when read time include an hour
|
16
|
+
it "returns the reading time in phrase form when read time include an hour & minutes" do
|
22
17
|
text = "word " * 22550
|
23
|
-
expect(text.time_to_read(250)).to eql "1 hour 30 minutes"
|
18
|
+
expect(text.time_to_read(250)).to eql "~ 1 hour 30 minutes"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns less than a minute' do
|
22
|
+
text = 'word ' * 5
|
23
|
+
expect(text.time_to_read(250)).to eql "Less than a minute"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "hours_in_words" do
|
28
28
|
it "correctly pluralizes 'hour' when hours to read is greater than one" do
|
29
29
|
text = "word " * 30000
|
30
|
-
expect(text.time_to_read(250)).to eql "2 hours"
|
30
|
+
expect(text.time_to_read(250)).to eql "~ 2 hours"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|