Skip to content

Read Time estimates the time required to read the article. Read Time also takes images in account while estimating the time.

Notifications You must be signed in to change notification settings

deepakmahakale/read-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Read Time

Build Status

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"

Usage

Install the gem using RubyGems

gem install read-time

or:

Add it to your Gemfile

gem 'read-time'

Include it in your program

require 'read-time'

Call the method on the text

@article.body.readtime #=> "2 minute read"

Configuration

# 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"

TODO

  • I18n support
  • Calculation based on images

About

Read Time estimates the time required to read the article. Read Time also takes images in account while estimating the time.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages