Parent

Methods

String


Public Instance Methods

' ) #=> string click to toggle source

Reduce the size of the current string to the given width by removing characters from the middle of the string and replacing them with ellipses. If the width is greater than the length of the string, the string is returned unchanged. If the width is less than the length of the ellipses, then the ellipses are returned.

    # File lib/logging/utils.rb, line 59
59:   def reduce( width, ellipses = '...')
60:     raise ArgumentError, "width cannot be negative: #{width}" if width < 0
61: 
62:     return self if length <= width
63: 
64:     remove = length - width + ellipses.length
65:     return ellipses.dup if remove >= length
66: 
67:     left_end = (length + 1 - remove) / 2
68:     right_start = left_end + remove
69: 
70:     left = self[0,left_end]
71:     right = self[right_start,length-right_start]
72: 
73:     left << ellipses << right
74:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.