#
# strquote.rb
#
#   Copyright (c) 1999,2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
#
#   This program is free software.
#   You can distribute/modify this program under the terms of
#   the GNU General Public License version 2 or later.
#

class String

  def quoted
    ret = ''
    str = self
    until str.empty? do
      m = /\n|\r\n|\r|\z/.match( str )
      part = m.pre_match
      while part and not part.empty? do
        tmp = part[ 0, 50 ].inspect
        ret << tmp[ 1, tmp.size - 2 ]
        part = part[ 50, str.size - 50 ]
      end
      tmp = m[0].inspect
      ret << tmp[ 1, tmp.size - 2 ]

      str = m.post_match
    end

    ret
  end

end
