ruby-win32/lib/ruby/site_ruby/1.8/rubygems/commands/query_command.rb
##
# Used for wrapping and indenting text
#
Used for wrapping and indenting text
Used for wrapping and indenting text
def format_text(text, wrap, indent=0)
    result = []
    work = text.dup
    while work.length > wrap
      if work =~ /^(.{0,#{wrap}})[ \n]/o then
        result << $1
        work.slice!(0, $&.length)
      else
        result << work.slice!(0, wrap)
      end
    end
    result << work if work.length.nonzero?
    result.join("\n").gsub(/^/, " " * indent)
  end
def format_text ( text , wrap , indent = 0 ) result = [ ] work = text . dup while work . length > wrap if work =~ / ^(.{0, #{ wrap } })[  \n ] /o then result << $1 work . slice! ( 0 , $& . length ) else result << work . slice! ( 0 , wrap ) end end result << work if work . length . nonzero? result . join ( "\n" ) . gsub ( / ^ / , " " * indent ) end
Used for wrapping and indenting text
Used for wrapping and indenting text
text
wrap
indent