Class: SocialProfile::People::Google

Inherits:
SocialProfile::Person show all
Defined in:
lib/social_profile/people/google.rb

Instance Attribute Summary

Attributes inherited from SocialProfile::Person

#access_token, #options, #uid

Instance Method Summary collapse

Methods inherited from SocialProfile::Person

#album!, #fetch_album, #find_album, #find_or_create_album, #followers_count, get, #initialize, #share_photo!, #tag_object!

Constructor Details

This class inherits a constructor from SocialProfile::Person

Instance Method Details

#channelsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/social_profile/people/google.rb', line 15

def channels
  return @channels if @channels

  _channels = client.list_channels('statistics', mine: true)

  @channels = if _channels.respond_to?(:items)
    _channels
  elsif _channels.is_a?(String)
    JSON.parse(_channels, object_class: OpenStruct)
  end

  @channels
end

#friends_countObject

Get friends count



9
10
11
12
13
# File 'lib/social_profile/people/google.rb', line 9

def friends_count
  @friends_count ||= channels.items.map do |item|
    (item.statistics.subscriber_count || item.statistics.subscriberCount).to_i
  end.sum
end