module Wordwrapper
Constants
- VERSION
Public Class Methods
undo(str)
click to toggle source
# File lib/wordwrapper.rb, line 13 def self.undo(str) str.gsub! "\n", " " end
wrap(str, max_len)
click to toggle source
# File lib/wordwrapper.rb, line 6 def self.wrap(str, max_len) return str if str.length <= max_len indexOfSpace = str[0, max_len].rindex(" ") part = indexOfSpace.nil? ? str[0, max_len] : str[0..indexOfSpace-1] part + "\n" + wrap(str[part.length..-1].strip, max_len) end