Class: SocialProfile::Person
- Inherits:
-
Object
- Object
- SocialProfile::Person
- Defined in:
- lib/social_profile/person.rb
Direct Known Subclasses
SocialProfile::People::Facebook, 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 |
# 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 else Person end klass.new(uid, access_token, ) end |
Instance Method Details
#album!(options = {}) ⇒ Object
Create new album id
32 33 34 |
# File 'lib/social_profile/person.rb', line 32 def album!( = {}) raise NotImplementedError("Subclasses should implement this!") end |
#fetch_album(album_id) ⇒ Object
Find album by id
27 28 29 |
# File 'lib/social_profile/person.rb', line 27 def fetch_album(album_id) raise NotImplementedError("Subclasses should implement this!") end |
#find_album(album_id) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/social_profile/person.rb', line 36 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
46 47 48 49 50 |
# File 'lib/social_profile/person.rb', line 46 def find_or_create_album(album_id, = {}) record = find_album(album_id) record ||= album!() record end |
#followers_count(options = {}) ⇒ Object
Get followers count
76 77 78 |
# File 'lib/social_profile/person.rb', line 76 def followers_count( = {}) nil end |
#friends_count(options = {}) ⇒ Object
Get friends count
71 72 73 |
# File 'lib/social_profile/person.rb', line 71 def friends_count( = {}) nil end |
#share_photo!(album_id, filepath, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/social_profile/person.rb', line 52 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
62 63 64 65 66 67 68 |
# File 'lib/social_profile/person.rb', line 62 def tag_object!(object, ) = Array.wrap() return if .empty? || object.nil? object.tag!(:tags => ) end |