Class: SocialProfile::Person
- Inherits:
-
Object
- Object
- SocialProfile::Person
- Defined in:
- lib/social_profile/person.rb
Direct Known Subclasses
SocialProfile::People::Facebook, SocialProfile::People::Google, SocialProfile::People::Instagram, SocialProfile::People::InstagramParser, SocialProfile::People::Twitter, SocialProfile::People::Vkontakte
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
-
#album!(options = {}) ⇒ Object
Create new album id.
-
#fetch_album(album_id) ⇒ Object
Find album by id.
- #find_album(album_id) ⇒ Object
- #find_or_create_album(album_id, options = {}) ⇒ Object
-
#followers_count(options = {}) ⇒ Object
Get followers count.
-
#friends_count(options = {}) ⇒ Object
Get friends count.
-
#initialize(uid, access_token, options = {}) ⇒ Person
constructor
A new instance of Person.
- #share_photo!(album_id, filepath, options = {}) ⇒ Object
- #tag_object!(object, tags) ⇒ Object
Constructor Details
#initialize(uid, access_token, options = {}) ⇒ Person
Returns a new instance of Person.
7 8 9 10 11 |
# File 'lib/social_profile/person.rb', line 7 def initialize(uid, access_token, = {}) @uid = uid @access_token = access_token @options = end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/social_profile/person.rb', line 5 def access_token @access_token end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/social_profile/person.rb', line 5 def @options end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
5 6 7 |
# File 'lib/social_profile/person.rb', line 5 def uid @uid end |
Class Method Details
.get(provider, uid, access_token, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/social_profile/person.rb', line 13 def self.get(provider, uid, access_token, = {}) return if provider.nil? klass = case provider.to_s when "facebook" then People::Facebook when "vkontakte" then People::Vkontakte when "twitter" then People::Twitter when "instagram" then People::Instagram when "instagram_parser" then People::InstagramParser when "google" then People::Google else Person end klass.new(uid, access_token, ) end |
Instance Method Details
#album!(options = {}) ⇒ Object
Create new album id
35 36 37 |
# File 'lib/social_profile/person.rb', line 35 def album!( = {}) raise NotImplementedError("Subclasses should implement this!") end |
#fetch_album(album_id) ⇒ Object
Find album by id
30 31 32 |
# File 'lib/social_profile/person.rb', line 30 def fetch_album(album_id) raise NotImplementedError("Subclasses should implement this!") end |
#find_album(album_id) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/social_profile/person.rb', line 39 def find_album(album_id) return if album_id.nil? begin fetch_album(album_id) rescue Exception => e return nil end end |
#find_or_create_album(album_id, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/social_profile/person.rb', line 49 def find_or_create_album(album_id, = {}) record = find_album(album_id) record ||= album!() record end |
#followers_count(options = {}) ⇒ Object
Get followers count
79 80 81 |
# File 'lib/social_profile/person.rb', line 79 def followers_count( = {}) nil end |
#friends_count(options = {}) ⇒ Object
Get friends count
74 75 76 |
# File 'lib/social_profile/person.rb', line 74 def friends_count( = {}) nil end |
#share_photo!(album_id, filepath, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/social_profile/person.rb', line 55 def share_photo!(album_id, filepath, = {}) album = find_or_create_album(album_id, [:album]) data = { :source => File.new(filepath) }.merge([:photo] || {}) album.photo!(data) end |
#tag_object!(object, tags) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/social_profile/person.rb', line 65 def tag_object!(object, ) = Array.wrap() return if .empty? || object.nil? object.tag!(:tags => ) end |