Module: HpricotTruncator::TextNode

Defined in:
app/helpers/text_helper.rb

Instance Method Summary collapse

Instance Method Details

#truncate(length) ⇒ Object



38
39
40
41
# File 'app/helpers/text_helper.rb', line 38

def truncate(length)
  # We're using String#scan because Hpricot doesn't distinguish entities.
  Hpricot::Text.new(content.scan(/&#?[^\W_]+;|./).first(length).join)
end