~ubuntu-branches/ubuntu/gutsy/racc/gutsy

« back to all changes in this revision

Viewing changes to packages/amstd/lib/amstd/strquote.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2002-01-08 21:48:51 UTC
  • Revision ID: james.westby@ubuntu.com-20020108214851-arrtgy8hcesowvix
Tags: upstream-1.4.1
ImportĀ upstreamĀ versionĀ 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# strquote.rb
 
3
#
 
4
#   Copyright (c) 1999,2000 Minero Aoki <aamine@loveruby.net>
 
5
#
 
6
#   This program is free software.
 
7
#   You can distribute/modify this program under the terms of
 
8
#   the GNU General Public License version 2 or later.
 
9
#
 
10
 
 
11
class String
 
12
 
 
13
  def quoted
 
14
    ret = ''
 
15
    str = self
 
16
    until str.empty? do
 
17
      m = /\n|\r\n|\r|\z/.match( str )
 
18
      part = m.pre_match
 
19
      while part and not part.empty? do
 
20
        tmp = part[ 0, 50 ].inspect
 
21
        ret << tmp[ 1, tmp.size - 2 ]
 
22
        part = part[ 50, str.size - 50 ]
 
23
      end
 
24
      tmp = m[0].inspect
 
25
      ret << tmp[ 1, tmp.size - 2 ]
 
26
 
 
27
      str = m.post_match
 
28
    end
 
29
 
 
30
    ret
 
31
  end
 
32
 
 
33
end