Parent

Methods

Files

String

Truncates a string to the given length and appends the given suffix if the string is, in fact, truncated.

Examples:

 "This is a long string right here".truncate(10, "...")  #=> "This is..."

Public Instance Methods

truncate(length = 30, truncate_string = "...") click to toggle source
    # File lib/merb-helpers/core_ext.rb, line 52
52:   def truncate(length = 30, truncate_string = "...")
53:     return self unless self.length > length
54:     length = length - truncate_string.split(//).length
55:     self[0...length] + truncate_string
56:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.