class Ppl::Entity::Contact

Attributes

birthday[RW]
email_addresses[RW]
id[RW]
name[RW]
nicknames[RW]
organizations[RW]
phone_numbers[RW]
postal_address[RW]
postal_addresses[RW]
urls[RW]

Public Class Methods

new() click to toggle source
# File lib/ppl/entity/contact.rb, line 14
def initialize
  @email_addresses = []
  @nicknames = []
  @organizations = []
  @phone_numbers = []
  @postal_addresses = []
  @urls = []
end

Public Instance Methods

age(on_date) click to toggle source
# 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() click to toggle source
# File lib/ppl/entity/contact.rb, line 39
def preferred_email_address
  @email_addresses.find { |e| e.preferred }
end
preferred_phone_number() click to toggle source
# File lib/ppl/entity/contact.rb, line 43
def preferred_phone_number
  @phone_numbers.find { |p| p.preferred }
end
set_postal_address() { |postal_address| ... } click to toggle source
# 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