Read Time estimates the time required to read the article. Read Time also takes images in account while estimating the time.
@article.body.readtime # => "1 minute read"
gem install read-time
or:
gem 'read-time'
require 'read-time'
@article.body.readtime #=> "2 minute read"
# config/initializers/read-time.rb
ReadTime.configure do |config|
config.reading_speed = 300
config.format = :default # [:default, :long]
end
Default values can be overriden:
text = 'word ' * 300
text.readtime #=> "2 minute read"
text.readtime(reading_speed: 300) #=> "1 minute read"
text.readtime(reading_speed: 200, format: :long) #=> "1 minute 30 second read"
- I18n support
- Calculation based on images