Class: ContactCsv::Contact
- Inherits:
-
Object
- Object
- ContactCsv::Contact
- Defined in:
- lib/contact_csv/contact.rb
Overview
Contact
Object that represents a Contact from an address book. This class is meant to support the most common attributes.
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#extras ⇒ Object
Returns a hash of all attributes that could not be mapped to a Contact class attribute.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#middle_name ⇒ Object
Returns the value of attribute middle_name.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#add_extra(extra) ⇒ Object
Adds an unmappable attribute.
-
#full_name ⇒ Object
First name and last name.
-
#initialize(attributes = {}) ⇒ Contact
constructor
Initializes a Contact objest and will take a hash of the attributes with values.
Constructor Details
#initialize(attributes = {}) ⇒ Contact
Initializes a Contact objest and will take a hash of the attributes with values
Contact.new(:first_name => “Willy”, :last_name => “Wonka”)
12 13 14 15 16 17 18 19 |
# File 'lib/contact_csv/contact.rb', line 12 def initialize(attributes={}) @extras = {} @first_name = attributes[:first_name] @middle_name = attributes[:middle_name] @last_name = attributes[:last_name] @email = attributes[:email] @title = attributes[:title] end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/contact_csv/contact.rb', line 7 def email @email end |
#extras ⇒ Object
Returns a hash of all attributes that could not be mapped to a Contact class attribute
22 23 24 |
# File 'lib/contact_csv/contact.rb', line 22 def extras @extras end |
#first_name ⇒ Object
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/contact_csv/contact.rb', line 7 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/contact_csv/contact.rb', line 7 def last_name @last_name end |
#middle_name ⇒ Object
Returns the value of attribute middle_name.
7 8 9 |
# File 'lib/contact_csv/contact.rb', line 7 def middle_name @middle_name end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/contact_csv/contact.rb', line 7 def title @title end |
Instance Method Details
#add_extra(extra) ⇒ Object
Adds an unmappable attribute
27 28 29 |
# File 'lib/contact_csv/contact.rb', line 27 def add_extra(extra) @extras.merge!(extra) end |
#full_name ⇒ Object
First name and last name
32 33 34 |
# File 'lib/contact_csv/contact.rb', line 32 def full_name [@first_name, @last_name].join(' ') end |