module RMail::Utils

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

Public Class Methods

base64_decode(str) click to toggle source

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

# File lib/rmail/utils.rb, line 47
def base64_decode(str)
  str.unpack("m*").first
end
quoted_printable_decode(str) click to toggle source

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

# File lib/rmail/utils.rb, line 53
def quoted_printable_decode(str)
  str.unpack("M*").first
end
unquote(str) click to toggle source

Return the given string unquoted if it is quoted.

# File lib/rmail/utils.rb, line 38
def unquote(str)
  if str =~ /\s*"(.*?([^\\]|\\\\))"/m
    $1.gsub(/\\(.)/, '\1')
  else
    str
  end
end