Class: SocialProfile::Providers::Facebook

Inherits:
Base
  • Object
show all
Defined in:
lib/social_profile/providers/facebook.rb

Instance Attribute Summary

Attributes inherited from Base

#auth_hash

Instance Method Summary collapse

Methods inherited from Base

#access_token, #avatar_url, #city_name, #credentials, #email, #extra, #extra?, #first_name, #info, #info?, #initialize, #last_name, #name, #nickname, #provider, #token_expires_at, #uid

Constructor Details

This class inherits a constructor from SocialProfile::Providers::Base

Instance Method Details

#birthdayObject



34
35
36
37
38
39
40
# File 'lib/social_profile/providers/facebook.rb', line 34

def birthday
  @birthday ||= begin
    Date.strptime(extra('raw_info')['birthday'],'%m/%d/%Y')
  rescue Exception => e
    nil
  end
end

#genderObject

0 - unknown 1 - female 2 - male Возвращаемые значения: 1 - женский, 2 - мужской, 0 - без указания пола.



26
27
28
29
30
31
32
# File 'lib/social_profile/providers/facebook.rb', line 26

def gender
  @gender ||= case extra('raw_info')['gender']
    when 'male' then 2
    when 'female' then 1
    else 0
  end
end

#picture_urlObject



8
9
10
11
12
13
# File 'lib/social_profile/providers/facebook.rb', line 8

def picture_url
  @picture_url ||= begin
    url = info('image').split('?').shift()
    check_url([url, "type=large"].join('?'))
  end
end

#profile_urlObject



15
16
17
18
19
20
# File 'lib/social_profile/providers/facebook.rb', line 15

def profile_url
  @profile_url ||= begin
    urls = info('urls')
    urls.nil? ? nil : urls['Facebook']
  end
end

#worksObject



46
47
48
49
# File 'lib/social_profile/providers/facebook.rb', line 46

def works
  return [] unless works?
  @works ||= extra('raw_info')['work']
end

#works?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/social_profile/providers/facebook.rb', line 42

def works?
  raw_info? && extra('raw_info')['work'] && extra('raw_info')['work'].is_a?(Array)
end