Class: String

Inherits:
Object show all
Defined in:
lib/deployable/patch/string/quoting.rb

Instance Method Summary collapse

Instance Method Details

#double_quoteObject



20
21
22
# File 'lib/deployable/patch/string/quoting.rb', line 20

def double_quote
  quote '"'
end

#needs_quoting?(check = /\s/) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/deployable/patch/string/quoting.rb', line 24

def needs_quoting? check = /\s/
  !!match(check)
end

#quote(char) ⇒ Object



3
4
5
6
7
# File 'lib/deployable/patch/string/quoting.rb', line 3

def quote char
  # improve this to escape chars, if they aren't already escaped
  raise if match char
  "#{char}#{self}#{char}"
end

#quote_escape(char) ⇒ Object



9
10
11
12
13
14
# File 'lib/deployable/patch/string/quoting.rb', line 9

def quote_escape char
  #if m = match char
  #  m.
  #end
  "#{char}#{self}#{char}"
end

#single_quoteObject



16
17
18
# File 'lib/deployable/patch/string/quoting.rb', line 16

def single_quote
  quote "'"
end