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.



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

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 (readonly)

Returns the value of attribute addresses.



9
10
11
# File 'lib/contacts.rb', line 9

def addresses
  @addresses
end

#emailsObject (readonly)

Returns the value of attribute emails.



9
10
11
# File 'lib/contacts.rb', line 9

def emails
  @emails
end

#firstnameObject (readonly)

Returns the value of attribute firstname.



9
10
11
# File 'lib/contacts.rb', line 9

def firstname
  @firstname
end

#imsObject (readonly)

Returns the value of attribute ims.



9
10
11
# File 'lib/contacts.rb', line 9

def ims
  @ims
end

#lastnameObject (readonly)

Returns the value of attribute lastname.



9
10
11
# File 'lib/contacts.rb', line 9

def lastname
  @lastname
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#noteObject

Returns the value of attribute note.



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

def note
  @note
end

#organizationsObject (readonly)

Returns the value of attribute organizations.



9
10
11
# File 'lib/contacts.rb', line 9

def organizations
  @organizations
end

#phonesObject (readonly)

Returns the value of attribute phones.



9
10
11
# File 'lib/contacts.rb', line 9

def phones
  @phones
end

#service_idObject

Returns the value of attribute service_id.



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

def service_id
  @service_id
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#emailObject



25
26
27
# File 'lib/contacts.rb', line 25

def email
  @emails.first
end

#inspectObject



29
30
31
# File 'lib/contacts.rb', line 29

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