zeus.ugent.be/lib/helpers/blog.rb

17 lines
317 B
Ruby
Raw Normal View History

2016-11-06 17:45:30 +01:00
require 'words_counted'
module BlogHelper
def reading_time(blogpost)
human_wpm = 200.0
2017-02-09 02:31:56 +01:00
words = WordsCounted.count(blogpost.compiled_content(rep: :text)).token_count
2016-11-06 17:45:30 +01:00
minutes = (words / human_wpm).ceil
if minutes == 1
"#{minutes} minuut"
else
"#{minutes} minuten"
end
end
end