bin/wrap.rb
##
# Wraps this string into an array of lines whose
# lengths are no greater than the given width.
#
Wraps this string into an array of lines whose
lengths are no greater than the given width.
Wraps this string into an array of lines whose lengths are no greater than the given width .
def wrap width
    lines = []
    lines << lstrip.scan(/\s*\S+/).inject('') do |line, word|
      len = line.length
      ext = word.length
      if len > 0 and len + ext > width
        lines << line
        line = word.lstrip
      else
        line << word
      end
    end
    lines
  end
def wrap width lines = [ ] lines << lstrip . scan ( / \s * \S + / ) . inject ( '' ) do | line , word | len = line . length ext = word . length if len > 0 and len + ext > width lines << line line = word . lstrip else line << word end end lines end
Wraps this string into an array of lines whose
lengths are no greater than the given width.
Wraps this string into an array of lines whose lengths are no greater than the given width .
# wrap current word onto the next line
width
<not_specific>