Class: Contacts::Contact::Yahoo

Inherits:
Struct
  • Object
show all
Defined in:
lib/contacts/contact/yahoo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



1
2
3
# File 'lib/contacts/contact/yahoo.rb', line 1

def email
  @email
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



1
2
3
# File 'lib/contacts/contact/yahoo.rb', line 1

def name
  @name
end

Class Method Details

.parse(hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/contacts/contact/yahoo.rb', line 3

def self.parse hash
  email, name = '', nil
  hash['fields'].each do |field|
    case field['type']
    when 'email'
      email = field['value']
    when 'name'
      name = [field['value']['givenName'], field['value']['familyName']].join(' ') rescue ''
    end
  end
  name ||= email
  new(email, name) unless email.nil? or email.empty?
end