def truncate(text, options={})
      options.reverse_merge!(:length => 30, :omission => "...")
      if text
        len = options[:length] - options[:omission].length
        chars = text
        (chars.length > options[:length] ? chars[0...len] + options[:omission] : text).to_s
      end
    end
def truncate(text, options={})
      options.reverse_merge!(:length => 30, :omission => "...")
      if text
        len = options[:length] - options[:omission].length
        chars = text
        (chars.length > options[:length] ? chars[0...len] + options[:omission] : text).to_s
      end
    end
Truncates a given text after a given :length if text is longer than :length (defaults to 30).
 The last characters will be replaced with the :omission (defaults to "в_│") for a total length not exceeding :length.

 ==== Examples

   truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."