Module: HpricotTruncator::TextNode
- Defined in:
- lib/text-helper.rb
Instance Method Summary collapse
Instance Method Details
#truncate(max_length) ⇒ Object
31 32 33 34 |
# File 'lib/text-helper.rb', line 31 def truncate(max_length) # We're using String#scan because Hpricot doesn't distinguish entities. Hpricot::Text.new(content.scan(/&#?[^\W_]+;|./).first(max_length).join) end |