Module: ContentTruncate::String

Included in:
String
Defined in:
lib/content_truncate.rb

Instance Method Summary collapse

Instance Method Details

#content_truncate(limit_length, *separators) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/content_truncate.rb', line 5

def content_truncate limit_length, *separators
  sub_string = self.dup
  sep = separators.shift
  if sep
    sub_string.send(:smart_truncate, limit_length, sep, *separators)
  else
    sub_string.truncate(limit_length, separator: sep)
  end
end