Class: Ppl::Entity::Contact
- Inherits:
-
Object
- Object
- Ppl::Entity::Contact
- Defined in:
- lib/ppl/entity/contact.rb
Instance Attribute Summary collapse
-
#birthday ⇒ Object
Returns the value of attribute birthday.
-
#email_addresses ⇒ Object
Returns the value of attribute email_addresses.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nicknames ⇒ Object
Returns the value of attribute nicknames.
-
#organizations ⇒ Object
Returns the value of attribute organizations.
-
#phone_numbers ⇒ Object
Returns the value of attribute phone_numbers.
-
#postal_address ⇒ Object
Returns the value of attribute postal_address.
-
#postal_addresses ⇒ Object
Returns the value of attribute postal_addresses.
-
#urls ⇒ Object
Returns the value of attribute urls.
Instance Method Summary collapse
- #age(on_date) ⇒ Object
-
#initialize ⇒ Contact
constructor
A new instance of Contact.
- #preferred_email_address ⇒ Object
- #preferred_phone_number ⇒ Object
- #set_postal_address {|@postal_address| ... } ⇒ Object
Constructor Details
#initialize ⇒ Contact
Returns a new instance of Contact.
14 15 16 17 18 19 20 21 |
# File 'lib/ppl/entity/contact.rb', line 14 def initialize @email_addresses = [] @nicknames = [] @organizations = [] @phone_numbers = [] @postal_addresses = [] @urls = [] end |
Instance Attribute Details
#birthday ⇒ Object
Returns the value of attribute birthday.
7 8 9 |
# File 'lib/ppl/entity/contact.rb', line 7 def birthday @birthday end |
#email_addresses ⇒ Object
Returns the value of attribute email_addresses.
6 7 8 |
# File 'lib/ppl/entity/contact.rb', line 6 def email_addresses @email_addresses end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/ppl/entity/contact.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ppl/entity/contact.rb', line 4 def name @name end |
#nicknames ⇒ Object
Returns the value of attribute nicknames.
5 6 7 |
# File 'lib/ppl/entity/contact.rb', line 5 def nicknames @nicknames end |
#organizations ⇒ Object
Returns the value of attribute organizations.
9 10 11 |
# File 'lib/ppl/entity/contact.rb', line 9 def organizations @organizations end |
#phone_numbers ⇒ Object
Returns the value of attribute phone_numbers.
8 9 10 |
# File 'lib/ppl/entity/contact.rb', line 8 def phone_numbers @phone_numbers end |
#postal_address ⇒ Object
Returns the value of attribute postal_address.
10 11 12 |
# File 'lib/ppl/entity/contact.rb', line 10 def postal_address @postal_address end |
#postal_addresses ⇒ Object
Returns the value of attribute postal_addresses.
11 12 13 |
# File 'lib/ppl/entity/contact.rb', line 11 def postal_addresses @postal_addresses end |
#urls ⇒ Object
Returns the value of attribute urls.
12 13 14 |
# File 'lib/ppl/entity/contact.rb', line 12 def urls @urls end |
Instance Method Details
#age(on_date) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ppl/entity/contact.rb', line 30 def age(on_date) if @birthday.nil? nil else # From http://stackoverflow.com/a/2357790 on_date.year - @birthday.year - ((on_date.month > @birthday.month || (on_date.month == @birthday.month && on_date.day >= @birthday.day)) ? 0 : 1) end end |
#preferred_email_address ⇒ Object
39 40 41 |
# File 'lib/ppl/entity/contact.rb', line 39 def preferred_email_address @email_addresses.find { |e| e.preferred } end |
#preferred_phone_number ⇒ Object
43 44 45 |
# File 'lib/ppl/entity/contact.rb', line 43 def preferred_phone_number @phone_numbers.find { |p| p.preferred } end |
#set_postal_address {|@postal_address| ... } ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ppl/entity/contact.rb', line 23 def set_postal_address if @postal_address.nil? @postal_address = Ppl::Entity::PostalAddress.new end yield @postal_address end |