jekyll-read-time 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-read-time/filter.rb +9 -10
- data/lib/jekyll-read-time/version.rb +1 -1
- 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: 18626cfffae3bbfcc6de3c034ec64eeb8e090b92
|
4
|
+
data.tar.gz: 4f910d55d004e41a2dcbd546f505c98edfa6da0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212ef884d7fb0dad19a7c6c6cab6e6b8c4d4a709e4731d7f16b778d14bcfbd05934b3157b2ee0d0f7e8976f4ef66ebc7e542d5adf2999601409445ae02bc9f18
|
7
|
+
data.tar.gz: 35e18d89cf0274e39af0abbd08a01278366feeccfa2d3a909680a48f9be541885c833db11cee793804cdbb78f918c935adc20934f9acf91702020422f97d411c
|
@@ -1,18 +1,17 @@
|
|
1
1
|
require "jekyll-read-time"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
WORD_PER_MINUTE = 180
|
3
|
+
WORD_PER_MINUTE = 180
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
def calculate_time( input )
|
6
|
+
words = input.split.size;
|
7
|
+
minutes = ( words / WORD_PER_MINUTE ).floor
|
8
|
+
return minutes
|
9
|
+
end
|
12
10
|
|
11
|
+
module JekyllReadTime
|
13
12
|
module ReadingTimeFilter
|
14
13
|
def read_time( input )
|
15
|
-
minutes =
|
14
|
+
minutes = calculate_time(input)
|
16
15
|
case minutes
|
17
16
|
when 2 then minutes_s = 'two'
|
18
17
|
when 3 then minutes_s = 'three'
|
@@ -31,7 +30,7 @@ module JekyllReadTime
|
|
31
30
|
|
32
31
|
module ReadingTimeFilterShort
|
33
32
|
def read_time_short( input )
|
34
|
-
minutes =
|
33
|
+
minutes = calculate_time(input)
|
35
34
|
minutes > 0 ? "#{minutes} min read" : "1 min read"
|
36
35
|
end
|
37
36
|
Liquid::Template.register_filter(JekyllReadTime::ReadingTimeFilterShort)
|