Sha256: cf88ec5e3781647d36715b4527a7e9f1279f4e88e4a64227c2a3dbb3c34dcb7c
Contents?: true
Size: 451 Bytes
Versions: 12
Compression:
Stored size: 451 Bytes
Contents
# Some mixed in functionality for String class String # Wrap a string to lines of a specified width. All existing newlines # are not guaranteed to be preserved def wrap(width) s = gsub(/\s+/, ' ').strip if s.length > width s[0...width] + '\n' + s[width..-1].wrap(width) else s end end # Indent each line of a string by n spaces def indent(n) indent = ' ' * n gsub '\n', "\n#{indent}" end end
Version data entries
12 entries across 12 versions & 2 rubygems