Class: EmailAddress
- Inherits:
-
Object
- Object
- EmailAddress
- Defined in:
- lib/email_api/email/data/email_address.rb
Overview
Contains all parameters that defines an email address
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name = nil, email = name) ⇒ EmailAddress
constructor
A new instance of EmailAddress.
- #to_hash ⇒ Object
Constructor Details
#initialize(name = nil, email = name) ⇒ EmailAddress
Returns a new instance of EmailAddress.
6 7 8 9 |
# File 'lib/email_api/email/data/email_address.rb', line 6 def initialize(name = nil, email = name) @name = name @email = email end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/email_api/email/data/email_address.rb', line 4 def email @email end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/email_api/email/data/email_address.rb', line 3 def name @name end |
Instance Method Details
#to_hash ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/email_api/email/data/email_address.rb', line 11 def to_hash hash = {} instance_variables.each do |var| name = var.to_s.delete('@') value = instance_variable_get(var) val_hash = value.to_hash if value.respond_to?(:to_hash) hash[name] = val_hash.nil? ? value : val_hash end hash end |