Class: GmailContacts::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/gmail-contacts.rb

Overview

An object that represents a single contact

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#emailsObject (readonly)

Returns the value of attribute emails.



11
12
13
# File 'lib/gmail-contacts.rb', line 11

def emails
  @emails
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/gmail-contacts.rb', line 11

def name
  @name
end

#usernameObject (readonly)

Returns the value of attribute username.



11
12
13
# File 'lib/gmail-contacts.rb', line 11

def username
  @username
end

Instance Method Details

#emailObject



20
21
22
# File 'lib/gmail-contacts.rb', line 20

def email
  @emails.first
end

#inspectObject



24
25
26
# File 'lib/gmail-contacts.rb', line 24

def inspect
  %!#<GmailContacts::Contact "#{name}"#{email ? " (#{email})" : ''}>!
end