Module: RMail::Utils

Defined in:
lib/rmail/utils.rb

Overview

The RMail::Utils module is a collection of random utility methods that are useful for dealing with email.

Class Method Summary collapse

Class Method Details

.base64_decode(str) ⇒ Object

Decode the given string as if it were a chunk of base64 data


47
48
49
# File 'lib/rmail/utils.rb', line 47

def base64_decode(str)
  str.unpack("m*").first
end

.quoted_printable_decode(str) ⇒ Object

Decode the given string as if it were a chunk of quoted printable data


53
54
55
# File 'lib/rmail/utils.rb', line 53

def quoted_printable_decode(str)
  str.unpack("M*").first
end

.unquote(str) ⇒ Object

Return the given string unquoted if it is quoted.


38
39
40
41
42
43
44
# File 'lib/rmail/utils.rb', line 38

def unquote(str)
  if str =~ /\s*"(.*?([^\\]|\\\\))"/m
    $1.gsub(/\\(.)/, '\1')
  else
    str
  end
end