Class: SocialProfile::Providers::Odnoklassniki

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

Instance Attribute Summary

Attributes inherited from Base

#auth_hash

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#birthdayObject



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

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

#city_nameObject



41
42
43
44
45
# File 'lib/social_profile/providers/odnoklassniki.rb', line 41

def city_name
  @city_name ||= begin
    location('city')
  end
end

#genderObject

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



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

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

#location(key) ⇒ Object



51
52
53
54
55
# File 'lib/social_profile/providers/odnoklassniki.rb', line 51

def location(key)
  if location? && Utils.exists?(extra('raw_info')['location'][key])
    extra('raw_info')['location'][key]
  end
end

#location?Boolean

Returns:

  • (Boolean)


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

def location?
  raw_info? && extra('raw_info')['location'] && extra('raw_info')['location'].is_a?(Hash)
end

#picture_urlObject



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

def picture_url
  @picture_url ||= begin
    url = info('image').gsub("photoType=4", "photoType=3")
    check_url(url)
  end
end

#profile_urlObject



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

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