class SocialProfile::Providers::Odnoklassniki

Public Instance Methods

birthday() click to toggle source
# 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_name() click to toggle source
# File lib/social_profile/providers/odnoklassniki.rb, line 41
def city_name
  @city_name ||= begin
    location('city')
  end
end
gender() click to toggle source

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

# 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) click to toggle source
# 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?() click to toggle source
# 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_url() click to toggle source
# 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_url() click to toggle source
# 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

Protected Instance Methods

check_url(url) click to toggle source
# File lib/social_profile/providers/odnoklassniki.rb, line 59
def check_url(url)
  response = Utils.head(url, :follow_redirects => false)

  if response.code == 302 && response.headers['location']
    [response.headers['location']].flatten.first
  else
    url
  end
end
raw_info?() click to toggle source
# File lib/social_profile/providers/odnoklassniki.rb, line 69
def raw_info?
  extra('raw_info') && extra('raw_info').is_a?(Hash)
end