Class: GmailContacts::Contact
- Inherits:
-
Object
- Object
- GmailContacts::Contact
- Defined in:
- lib/gmail-contacts.rb
Overview
An object that represents a single contact
Instance Attribute Summary collapse
-
#emails ⇒ Object
readonly
Returns the value of attribute emails.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #email ⇒ Object
-
#initialize(email, name = nil, username = nil) ⇒ Contact
constructor
A new instance of Contact.
- #inspect ⇒ Object
Constructor Details
#initialize(email, name = nil, username = nil) ⇒ Contact
Returns a new instance of Contact.
13 14 15 16 17 18 |
# File 'lib/gmail-contacts.rb', line 13 def initialize(email, name = nil, username = nil) @emails = [] @emails << email if email @name = name @username = username end |
Instance Attribute Details
#emails ⇒ Object (readonly)
Returns the value of attribute emails.
11 12 13 |
# File 'lib/gmail-contacts.rb', line 11 def emails @emails end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/gmail-contacts.rb', line 11 def name @name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/gmail-contacts.rb', line 11 def username @username end |
Instance Method Details
#email ⇒ Object
20 21 22 |
# File 'lib/gmail-contacts.rb', line 20 def email @emails.first end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/gmail-contacts.rb', line 24 def inspect %!#<GmailContacts::Contact "#{name}"#{email ? " (#{email})" : ''}>! end |