Class: Contacts::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/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, firstname = nil, lastname = nil) ⇒ Contact

Returns a new instance of Contact.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/contacts.rb', line 14

def initialize(email, name = nil, username = nil, firstname = nil, lastname = nil)
  @emails = []
  @emails << email if email
  @ims = []
  @phones = []
  @addresses = []
  @organizations = []
  @name = name
  @username = username
  @firstname = firstname
  @lastname = lastname
end

Instance Attribute Details

#addressesObject

Returns the value of attribute addresses.



12
13
14
# File 'lib/contacts.rb', line 12

def addresses
  @addresses
end

#emailsObject

Returns the value of attribute emails.



12
13
14
# File 'lib/contacts.rb', line 12

def emails
  @emails
end

#firstnameObject (readonly)

Returns the value of attribute firstname.



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

def firstname
  @firstname
end

#imsObject

Returns the value of attribute ims.



12
13
14
# File 'lib/contacts.rb', line 12

def ims
  @ims
end

#lastnameObject (readonly)

Returns the value of attribute lastname.



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

def lastname
  @lastname
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/contacts.rb', line 12

def name
  @name
end

#noteObject

Returns the value of attribute note.



12
13
14
# File 'lib/contacts.rb', line 12

def note
  @note
end

#organizationsObject (readonly)

Returns the value of attribute organizations.



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

def organizations
  @organizations
end

#phonesObject

Returns the value of attribute phones.



12
13
14
# File 'lib/contacts.rb', line 12

def phones
  @phones
end

#service_idObject

Returns the value of attribute service_id.



12
13
14
# File 'lib/contacts.rb', line 12

def service_id
  @service_id
end

#usernameObject

Returns the value of attribute username.



12
13
14
# File 'lib/contacts.rb', line 12

def username
  @username
end

Instance Method Details

#emailObject



27
28
29
# File 'lib/contacts.rb', line 27

def email
  @emails.first
end

#inspectObject



31
32
33
# File 'lib/contacts.rb', line 31

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