module SmartExcerpt::Util

Public Instance Methods

decode(str) click to toggle source
# File lib/smart_excerpt/util.rb, line 3
def decode(str)
  SmartExcerpt.he.decode(str)
end
decode_and_strip(str) click to toggle source
# File lib/smart_excerpt/util.rb, line 15
def decode_and_strip(str)
  self.strip_tags(self.decode(str))
end
encode(str) click to toggle source
# File lib/smart_excerpt/util.rb, line 7
def encode(str)
  SmartExcerpt.he.encode(str)
end
simple_format(str) click to toggle source
# File lib/smart_excerpt/util.rb, line 19
def simple_format(str)
  SmartExcerpt.h.simple_format(str)
end
strip_tags(str) click to toggle source
# File lib/smart_excerpt/util.rb, line 11
def strip_tags(str)
  SmartExcerpt.h.strip_tags(str)
end
truncate(str, opts = {}) click to toggle source
# File lib/smart_excerpt/util.rb, line 23
def truncate(str, opts = {})
  return '' if str.blank?
  tx = str.gsub(/<h\d[^>]*?>(.*)<\/h\d>/mi, '').gsub("\n", ' ').gsub("\r", '').gsub("\t", '').strip
  tx = SmartExcerpt.he.decode(tx)
  tx = SmartExcerpt.h.strip_tags(tx)
  SmartExcerpt.h.smart_truncate(tx, opts)
end