Sha256: 527ffcac7c95bd532cfd52da54e1ba6f26b176596e7c91144b200b91513258b8
Contents?: true
Size: 318 Bytes
Versions: 10
Compression:
Stored size: 318 Bytes
Contents
class String # Line wrap at width. # # s = "1234567890".line_wrap(5) # # s #=> "12345\n67890\n" # # CREDIT: Trans def line_wrap(width, tabs=4) s = gsub(/\t/,' ' * tabs) # tabs default to 4 spaces s = s.gsub(/\n/,' ') r = s.scan( /.{1,#{width}}/ ) r.join("\n") << "\n" end end
Version data entries
10 entries across 9 versions & 2 rubygems