#!/usr/bin/env ruby # This code comes from http://ruby-it.org/pages/Word+Wrap # Check the page for copyright notice and explanations def wordwrap(str, lunghezza ) str.gsub( /\n/, "\n\n" ).gsub( /(.{1,#{lunghezza}})(\s+|$)/, "\\1\n" ) end class String def wordwrap( lung=72 ) gsub( /\n/, "\n\n" ).gsub( /(.{1,#{lun}})(\s+|$)/, "\\1\n" ) end end require 'text/format' formattatore = Text::Format.new { @columns = 72 } formattatore.format( stringa ) Text::Format.new { @columns = 68 @first_indent = 0 }