Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Merge pull request #5 from maxehmookau/patch-1

Add MIT Licence to the project
latest commit d11373d805
@garethrees authored

Estimate Reading Time

Build Status Code Climate

I use iA Writer and find the estimated reading time feature pretty handy. I thought it would be cool to add at the top of my blog articles on the web as others do.

How to Use

readingtime extends the Ruby String class, so you can call reading_time on any String object.


gem install readingtime

In irb

$ irb
> require 'readingtime'
=> true
> @words = "Lorem ipsum dolor sit amet"
> @words.reading_time
=> "00:01"

In Your App


    <h1><%= @article.title %></h1>
    <span class="readingtime">Estimated reading time – <%= @article.body.reading_time %></span>

  <%= @article.body %>


And voila!

Screenshot of readingtime in use


You can also send in options to modify the formatting.

# Default output
@article.body.reading_time :format => :basic
=> "03:36"

# Longer text output
@article.body.reading_time :format => :long
=> "3 minutes and 36 seconds"

# Full text output
@article.body.reading_time :format => :full
=> "1 hr 3 mins 36 secs"

# Raw output [hours, minutes, seconds]
@article.body.reading_time :format => :raw
=> [1, 12, 23]


Credit goes to Brian Cray for explaining how to do it in PHP.

Something went wrong with that request. Please try again.