Sha256: 86a56c5de40dca9f153449bacd5bb616084027c7ba68ec889909c98550013346

Contents?: true

Size: 214 Bytes

Versions: 5

Compression:

Stored size: 214 Bytes

Contents

class String
  def wrap(width)
    self.split("\n").collect { |line|
      if line.length > width
        line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip
      else
        line
      end
    } * "\n"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tp-0.3.1 lib/string.rb
tp-0.3.0 lib/string.rb
tp-0.2.1 lib/string.rb
tp-0.2.0 lib/string.rb
tp-0.1.1 lib/string.rb