Object
Truncates a string to the given length and appends the given suffix if the string is, in fact, truncated.
"This is a long string right here".truncate(10, "...") #=> "This is..."
# File lib/merb-helpers/core_ext.rb, line 52 def truncate(length = 30, truncate_string = "...") return self unless self.length > length length = length - truncate_string.split(//).length self[0...length] + truncate_string end
[Validate]
Generated with the Darkfish Rdoc Generator 2.