2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/pkgr/env_value.rb', line 2
def quote(type=:double, count=nil)
if Integer === type
tmp = count
count = type
type = tmp || :mixed
else
count ||= 1
end
type = type.to_s unless Integer===type
case type
when "'", 'single', 's', 1
f = "'" * count
b = f
when '"', 'double', 'd', 2
f = '"' * count
b = f
when '`', 'back', 'b', -1
f = '`' * count
b = f
when "`'", 'bracket', 'sb'
f = "`" * count
b = "'" * count
when "'\"", 'mixed', "m", Integer
c = (count.to_f / 2).to_i
f = '"' * c
b = f
if count % 2 != 0
f = "'" + f
b = b + "'"
end
else
raise ArgumentError, "unrecognized quote type -- #{type}"
end
"#{f}#{self}#{b}"
end
|