Module: SmartExcerpt::Util
- Included in:
- SmartExcerpt
- Defined in:
- lib/smart_excerpt/util.rb
Instance Method Summary collapse
- #decode(str) ⇒ Object
- #decode_and_strip(str) ⇒ Object
- #encode(str) ⇒ Object
- #simple_format(str) ⇒ Object
- #strip_tags(str) ⇒ Object
- #truncate(str, opts = {}) ⇒ Object
Instance Method Details
#decode(str) ⇒ Object
3 4 5 |
# File 'lib/smart_excerpt/util.rb', line 3 def decode(str) SmartExcerpt.he.decode(str) end |
#decode_and_strip(str) ⇒ Object
15 16 17 |
# File 'lib/smart_excerpt/util.rb', line 15 def decode_and_strip(str) self.(self.decode(str)) end |
#encode(str) ⇒ Object
7 8 9 |
# File 'lib/smart_excerpt/util.rb', line 7 def encode(str) SmartExcerpt.he.encode(str) end |
#simple_format(str) ⇒ Object
19 20 21 |
# File 'lib/smart_excerpt/util.rb', line 19 def simple_format(str) SmartExcerpt.h.simple_format(str) end |
#strip_tags(str) ⇒ Object
11 12 13 |
# File 'lib/smart_excerpt/util.rb', line 11 def (str) SmartExcerpt.h.(str) end |
#truncate(str, opts = {}) ⇒ Object
23 24 25 26 27 28 29 |
# 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.(tx) SmartExcerpt.h.smart_truncate(tx, opts) end |