Module: Summarise::StringExtensions
- Included in:
- String
- Defined in:
- lib/summarise/string_extensions.rb
Instance Method Summary collapse
- #summarisable?(length = 200) ⇒ Boolean (also: #summarizable?)
- #summarise(l = 200, args = {}) ⇒ Object (also: #summarize)
Instance Method Details
#summarisable?(length = 200) ⇒ Boolean Also known as: summarizable?
13 14 15 |
# File 'lib/summarise/string_extensions.rb', line 13 def summarisable?(length=200) return self.summarise(length) != self end |
#summarise(l = 200, args = {}) ⇒ Object Also known as: summarize
4 5 6 7 8 9 10 11 |
# File 'lib/summarise/string_extensions.rb', line 4 def summarise(l=200, args={}) i = 0 summary = self.split.map{ |word| word if (i += word.length) < l}.compact.join(' ') if args[:suffix] && self != summary summary << args[:suffix] end summary end |