Skip to content

Instantly share code, notes, and snippets.

@micahbrich
Created November 21, 2012 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micahbrich/4127466 to your computer and use it in GitHub Desktop.
Save micahbrich/4127466 to your computer and use it in GitHub Desktop.
Reading Time
def reading_time(content)
wordcount = content.to_s.scan(/(\w|-)+/).length.to_f # count words
reading_time_in_s = (wordcount / 275)*60 # avg american reading time is around 250 words per minute
reading_time = Time.at(reading_time_in_s).gmtime.strftime("%-M minutes, %-S seconds") #convert to pretty string
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment