Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/vmail/string_ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.shellescape(str) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vmail/string_ext.rb', line 10

def self.shellescape(str)
  # An empty argument will be skipped, so return empty quotes.
  return "''" if str.empty?

  str = str.dup

  # Process as a single byte sequence because not all shell
  # implementations are multibyte aware.
  str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")

  # A LF cannot be escaped with a backslash because a backslash + LF
  # combo is regarded as line continuation and simply ignored.
  str.gsub!(/\n/, "'\n'")

  return str
end

Instance Method Details

#col(width) ⇒ Object



2
3
4
# File 'lib/vmail/string_ext.rb', line 2

def col(width)
  self[0,width].ljust(width)
end

#rcol(width) ⇒ Object

right justified



6
7
8
# File 'lib/vmail/string_ext.rb', line 6

def rcol(width) #right justified
  self[0,width].rjust(width)
end