Class String
In: merb-core/lib/merb-core/test/test_ext/string.rb
merb-helpers/lib/merb-helpers/core_ext.rb
Parent: Object

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..."

Methods

contain?   contains?   match?   matches?   truncate  

Public Instance methods

[Source]

   # File merb-core/lib/merb-core/test/test_ext/string.rb, line 2
2:   def contain?(value)
3:     self.include?(value)
4:   end
contains?(value)

Alias for contain?

[Source]

    # File merb-core/lib/merb-core/test/test_ext/string.rb, line 8
 8:   def match?(regex)
 9:     self.match(regex)
10:   end
matches?(regex)

Alias for match?

[Source]

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

[Validate]