Class: ADN::User
- Inherits:
-
Object
- Object
- ADN::User
- Defined in:
- lib/adnruby.rb
Instance Attribute Summary collapse
-
#avatar_image ⇒ Object
Returns the value of attribute avatar_image.
-
#counts ⇒ Object
Returns the value of attribute counts.
-
#cover_image ⇒ Object
Returns the value of attribute cover_image.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#follows_you ⇒ Object
Returns the value of attribute follows_you.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_follower ⇒ Object
Returns the value of attribute is_follower.
-
#is_following ⇒ Object
Returns the value of attribute is_following.
-
#is_muted ⇒ Object
Returns the value of attribute is_muted.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#name ⇒ Object
Returns the value of attribute name.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#username ⇒ Object
Returns the value of attribute username.
-
#you_follow ⇒ Object
Returns the value of attribute you_follow.
-
#you_muted ⇒ Object
Returns the value of attribute you_muted.
Instance Method Summary collapse
- #details ⇒ Object
-
#follow(user) ⇒ Object
Followers/Users.
- #followers ⇒ Object
- #following ⇒ Object
-
#has_error? ⇒ Boolean
Errors.
-
#initialize(user_id) ⇒ User
constructor
A new instance of User.
- #mentions(params = nil) ⇒ Object
-
#mute(user) ⇒ Object
Mute.
- #mute_list ⇒ Object
-
#posts(params = nil) ⇒ Object
Posts.
- #stream(params = nil) ⇒ Object
- #unfollow(user) ⇒ Object
- #unmute(user) ⇒ Object
Constructor Details
#initialize(user_id) ⇒ User
Returns a new instance of User.
46 47 48 49 50 51 52 53 54 |
# File 'lib/adnruby.rb', line 46 def initialize(user_id) @user_id = user_id details = self.details if details.has_key? "data" details["data"].each do |k, v| self.instance_variable_set "@#{k}", v end end end |
Instance Attribute Details
#avatar_image ⇒ Object
Returns the value of attribute avatar_image.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def avatar_image @avatar_image end |
#counts ⇒ Object
Returns the value of attribute counts.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def counts @counts end |
#cover_image ⇒ Object
Returns the value of attribute cover_image.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def cover_image @cover_image end |
#created_at ⇒ Object
Returns the value of attribute created_at.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def description @description end |
#follows_you ⇒ Object
Returns the value of attribute follows_you.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def follows_you @follows_you end |
#id ⇒ Object
Returns the value of attribute id.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def id @id end |
#is_follower ⇒ Object
Returns the value of attribute is_follower.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def is_follower @is_follower end |
#is_following ⇒ Object
Returns the value of attribute is_following.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def is_following @is_following end |
#is_muted ⇒ Object
Returns the value of attribute is_muted.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def is_muted @is_muted end |
#locale ⇒ Object
Returns the value of attribute locale.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def locale @locale end |
#name ⇒ Object
Returns the value of attribute name.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def name @name end |
#timezone ⇒ Object
Returns the value of attribute timezone.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def timezone @timezone end |
#type ⇒ Object
Returns the value of attribute type.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def type @type end |
#user_id ⇒ Object
Returns the value of attribute user_id.
43 44 45 |
# File 'lib/adnruby.rb', line 43 def user_id @user_id end |
#username ⇒ Object
Returns the value of attribute username.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def username @username end |
#you_follow ⇒ Object
Returns the value of attribute you_follow.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def you_follow @you_follow end |
#you_muted ⇒ Object
Returns the value of attribute you_muted.
44 45 46 |
# File 'lib/adnruby.rb', line 44 def you_muted @you_muted end |
Instance Method Details
#details ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/adnruby.rb', line 56 def details if self.id h = {} self.instance_variables.each { |iv| h[iv.to_s.gsub(/[^a-zA-Z0-9_]/, '')] = self.instance_variable_get(iv) } h else ADN::Users.retrieve(@user_id) end end |
#follow(user) ⇒ Object
Followers/Users
69 70 71 72 73 |
# File 'lib/adnruby.rb', line 69 def follow(user) user_id = user.is_a?(ADN::User) ? user.id : user result = ADN.post("/stream/0/users/#{user_id}/follow") result["data"] unless result.has_error? end |
#followers ⇒ Object
81 82 83 84 |
# File 'lib/adnruby.rb', line 81 def followers result = ADN::Users.followers(@user_id) result["data"] unless result.has_error? end |
#following ⇒ Object
86 87 88 89 |
# File 'lib/adnruby.rb', line 86 def following result = ADN::Users.following(@user_id) result["data"] unless result.has_error? end |
#has_error? ⇒ Boolean
Errors
131 132 133 |
# File 'lib/adnruby.rb', line 131 def has_error? self.id.nil? end |
#mentions(params = nil) ⇒ Object
124 125 126 127 |
# File 'lib/adnruby.rb', line 124 def mentions(params = nil) result = ADN::Post.mentioning_user(@user_id, params) result["data"] unless result.has_error? end |
#mute(user) ⇒ Object
Mute
94 95 96 97 98 |
# File 'lib/adnruby.rb', line 94 def mute(user) user_id = user.is_a?(ADN::User) ? user.id : user result = ADN.post("/stream/0/users/#{user_id}/mute") result["data"] unless result.has_error? end |
#mute_list ⇒ Object
106 107 108 109 |
# File 'lib/adnruby.rb', line 106 def mute_list result = ADN.get("/stream/0/users/me/muted") result["data"] unless result.has_error? end |
#posts(params = nil) ⇒ Object
Posts
114 115 116 117 |
# File 'lib/adnruby.rb', line 114 def posts(params = nil) result = ADN::Post.by_user(@user_id, params) result["data"] unless result.has_error? end |
#stream(params = nil) ⇒ Object
119 120 121 122 |
# File 'lib/adnruby.rb', line 119 def stream(params = nil) result = ADN::Post.stream(params) result["data"] unless result.has_error? end |