Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#time_to_read(string) ⇒ Object



1
2
3
4
5
6
7
8
9
# File 'lib/readingtime.rb', line 1

def time_to_read(string)
  words = string.scan(/\w+/).size
  time = (words.to_f/180).ceil
  if time == 1
    "less than a minute"
  else
    "about #{time} minutes"
  end
end