Module: Summarise::StringExtensions

Included in:
String
Defined in:
lib/summarise/string_extensions.rb

Instance Method Summary collapse

Instance Method Details

#summarisable?(length = 200) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/summarise/string_extensions.rb', line 9

def summarisable?(length=200)
  return self.summarise(length) != self
end

#summarise(l = 200) ⇒ Object



4
5
6
7
# File 'lib/summarise/string_extensions.rb', line 4

def summarise(l=200)
  i = 0
  self.split.map{ |word| word if (i += word.length) < l}.compact.join(' ')
end