Method: EmailAddress::Address#initialize

Defined in:
lib/email_address/address.rb

#initialize(email_address, config = {}) ⇒ Address

Given an email address of the form “local@hostname”, this sets up the instance, and initializes the address to the “normalized” format of the address. The original string is available in the #original method.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/email_address/address.rb', line 19

def initialize(email_address, config={})
  email_address.strip! if email_address
  @original      = email_address
  email_address||= ""
  if lh = email_address.match(/(.+)@(.+)/)
    (_, local, host) = lh.to_a
  else
    (local, host)    = [email_address, '']
  end
  @host         = EmailAddress::Host.new(host, config)
  @config       = @host.config
  @local        = EmailAddress::Local.new(local, @config)
end