struct Athena::MIME::Address
- Athena::MIME::Address
- Struct
- Value
- Object
Overview
Represents an email address with an optional name.
Defined in:
address.crConstructors
-
.create(address : self | String) : self
Creates a new
AMIME::Address
. -
.new(address : String, name : String = "")
Creates a new
AMIME::Address
with the provided address and optionally name.
Class Method Summary
-
.create_multiple(addresses : Enumerable(self | String)) : Array(self)
Creates an array of
AMIME::Address
from the provided enumerable addresses. -
.create_multiple(*addresses : self | String) : Array(self)
Creates an array of
AMIME::Address
from the provided addresses.
Instance Method Summary
-
#address : String
Returns the raw email address portion of this Address.
-
#clone
Returns a copy of
self
with all instance variables cloned. -
#encoded_address : String
Returns an encoded representation of
#address
safe to use within a MIME header. -
#encoded_name : String
Returns an encoded representation of
#name
safe to use within a MIME header. -
#has_unicode_local_part? : Bool
Returns
true
if this Address's localpart contains at least one non-ASCII character. -
#name : String
Returns the raw name portion of this Address, or an empty string if none was set.
-
#to_s(io : IO) : Nil
Writes an encoded representation of this Address to the provided io for use in a MIME header.
Constructor Detail
Creates a new AMIME::Address
.
If the address is already an AMIME::Address
, it is returned as is.
Otherwise if it's a String
, then attempt to parse the name and address from the provided string.
Creates a new AMIME::Address
with the provided address and optionally name.
Class Method Detail
Creates an array of AMIME::Address
from the provided enumerable addresses.
AMIME::Address.create_multiple({"[email protected]", "Mr Smith <[email protected]>", AMIME::Address.new("[email protected]")}) # =>
# [
# Athena::MIME::Address(@address="[email protected]", @name=""),
# Athena::MIME::Address(@address="[email protected]", @name="Mr Smith"),
# Athena::MIME::Address(@address="[email protected]", @name=""),
# ]
Creates an array of AMIME::Address
from the provided addresses.
AMIME::Address.create_multiple "[email protected]", "Mr Smith <[email protected]>", AMIME::Address.new("[email protected]") # =>
# [
# Athena::MIME::Address(@address="[email protected]", @name=""),
# Athena::MIME::Address(@address="[email protected]", @name="Mr Smith"),
# Athena::MIME::Address(@address="[email protected]", @name=""),
# ]
Instance Method Detail
Returns the raw email address portion of this Address.
Use #encoded_address
to get a safe representation for use in a MIME header.
address = AMIME::Address.new "[email protected]", "First Last"
address.address # => "[email protected]"
Returns an encoded representation of #address
safe to use within a MIME header.
AMIME::Address.new("contact@athenï.org").encoded_address # => "xn--athen-gta.org"
Returns an encoded representation of #name
safe to use within a MIME header.
AMIME::Address.new("[email protected]", %(Me, "You)).encoded_name # => "Me, \"You"
Returns true
if this Address's localpart contains at least one non-ASCII character.
Otherwise returns false
.
AMIME::Address.new("info@dømi.com").has_unicode_local_part? # => false
AMIME::Address.new("dømi@dømi.com").has_unicode_local_part? # => true
Returns the raw name portion of this Address, or an empty string if none was set.
Use #encoded_name
to get a safe representation for use in a MIME header.
address = AMIME::Address.new "[email protected]"
address.name # => ""
address = AMIME::Address.new "[email protected]", "First Last"
address.name # => "First Last"
Writes an encoded representation of this Address to the provided io for use in a MIME header.
AMIME::Address.new "contact@athenï.org", "George").to_s # => "\"George\" <[email protected]>"