Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/feedme-util.rb

Instance Method Summary collapse

Instance Method Details

#trunc(wordcount, tail = '...') ⇒ Object



39
40
41
42
43
44
# File 'lib/feedme-util.rb', line 39

def trunc(wordcount, tail='...')
  words = self.split
  truncated = words[0..(wordcount-1)].join(' ')
  truncated += tail if words.size > wordcount
  truncated
end