Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/stackfu.rb
Instance Method Summary collapse
Instance Method Details
#truncate_words(length = 30, end_string = '…') ⇒ Object
86 87 88 89 |
# File 'lib/stackfu.rb', line 86 def truncate_words(length = 30, end_string = '…') words = self.split() words[0..(length-1)].join(' ') + (words.length > length ? end_string : '') end |