class Wrapper
Public Instance Methods
wrap(string, max_length)
click to toggle source
# File lib/word_wrapper.rb, line 2 def wrap(string, max_length) return string if string.length <= max_length position = string[0..max_length].rindex(" ") || max_length string[0...position] +"\n" +wrap(string[position.. -1].lstrip,max_length) end