Class Mail::Address
In: /home/matt/rubymail/mail/address.rb
Parent: Object
This class provides the following functionality:

Methods
address    comments    comments=    display_name    display_name=    domain    domain=    format    local    local=    name    new    parse   
Public Class methods
new(string = nil)
Create a new address. If the string argument is not nil, it is parsed for mail addresses and if one is found, it is used to initialize this object.

See mail/deliver.rb

parse(string)
Given a string, this function attempts to extract mailing addresses from it. The function returns an array of Mail::Address objects. A malformed input string will not generate an exception. Instead, the array returned will be empty.

The string is expected to be in a valid format as documented in RFC2822's mailbox-list grammar. Some commonly seen invalid input is also handled correctly. This will work for lists of addresses in the To:, From:, etc. headers in email.

Public Instance methods
local()
Retrieve the local portion of the mail address. This is the portion that precedes the @ sign.
local=(l)
Assign the local portion of the mail address. This is the portion that precedes the @ sign.
display_name()
Returns the display name of this address. The display name is present only for "angle addr" style addresses such as:

      John Doe <johnd@example.net>

In this case, the display name will be "John Doe". In particular this old style address has no display name:

      bobs@example.net (Bob Smith)

See also display_name=, #name

display_name=(str)
Assign a display name to this address. See display_name for a definition of what this is.

See also display_name

name()
Returns a best guess at a display name for this email address. This function first checks if the address has a true display name (see display_name) and returns it if so. Otherwise, if the address has any comments, the last comment will be returned.

In most cases, this will behave reasonably. For example, it will return "Bob Smith" for this address:

      bobs@example.net (Bob Smith)

See also display_name, #comments, #comments=

comments()
Returns the comments in this address as an array of strings.
comments=(comments)
Set the comments for this address. The comments argument can be a string, or an array of strings. In either case, any existing comments are replaced.

See also #comments, #name

domain()
Retrieve to the domain portion of the mail address. This is the portion after the @ sign.
domain=(domain)
Assign a domain name to this address. This is the portion after the @ sign. Any existing domain name will be changed.
address()
Returns the email address portion of the address (i.e. without a display name, angle addresses, or comments).

The string returned is not suitable for insertion into an e-mail. RFC2822 quoting rules are not followed. The raw address is returned instead.

For example, if the local part requires quoting, this function will not perform the quoting (see #format for that). So this function can returns strings such as:

 "address with no quoting@example.net"

See also #format

format()
Return this address as a String formated as appropriate for insertion into a mail message.