Class: Turntabler::User
Overview
Represents an unauthorized user on Turntable
Direct Known Subclasses
Instance Attribute Summary collapse
-
#about ⇒ String
readonly
A brief description about the user.
-
#acl ⇒ Fixnum
readonly
The access control determining what is authorized.
-
#avatar ⇒ Turntabler::Avatar
readonly
The user’s currently active avatar.
-
#facebook_url ⇒ String
readonly
The user’s unique identifier on Facebook.
-
#fans_count ⇒ Fixnum
readonly
The number of fans this user has.
-
#hangout ⇒ String
readonly
A description of the rooms on Turntable the user likes to hang out.
-
#id ⇒ String
readonly
Allow the id to be set via the “userid” attribute.
-
#laptop_name ⇒ String
readonly
The name of the laptop the DJ uses.
-
#laptop_version ⇒ String
readonly
The version # for the laptop.
-
#name ⇒ String
readonly
The DJ name for this user.
-
#points ⇒ Fixnum
readonly
The total number of points accumulated all-time.
-
#sticker_placements(reload = false) ⇒ Array<Turntabler::StickerPlacement>
readonly
Gets the stickers that are currently placed on the user’s laptop.
-
#top_artists ⇒ String
readonly
The user’s favorite artists.
-
#twitter_id ⇒ String
readonly
The user’s unique identifier on Twitter.
-
#website ⇒ String
readonly
The user’s personal website.
Instance Method Summary collapse
-
#add_as_moderator ⇒ Object
Adds the user as a moderator in the current room.
-
#become_fan ⇒ true
Marks the current user as a fan of this user.
-
#block ⇒ true
Blocks this user from being able to send private messages.
-
#boot(reason = '') ⇒ true
Boots the user for the specified reason.
-
#dj? ⇒ Boolean
Is the user currently DJing in the room?.
-
#listener? ⇒ Boolean
Is the user currently a listener in the room?.
-
#load ⇒ true
Loads the attributes for this user.
-
#messages ⇒ Array<Turntabler::Message>
Gets the private conversation history with this user.
-
#moderator? ⇒ Boolean
Is the user currently a moderator for the room?.
-
#presence ⇒ String
Gets the availability status for this user.
-
#remove_as_dj ⇒ true
Stops the user from DJing.
-
#remove_as_moderator ⇒ true
Removes the user from being a moderator in the current room.
-
#report(reason = '') ⇒ true
Reports abuse by a user.
-
#say(content) ⇒ true
Sends a private message to this user.
-
#stalk ⇒ Turntabler::Room
Gets the location of the user.
-
#unblock ⇒ true
Unblocks this user from being able to send private messages.
-
#unfan ⇒ true
Marks the current user no longer as a fan of this user.
Methods inherited from Resource
#==, attribute, #attributes=, #hash, #initialize, #loaded?, #pretty_print, #pretty_print_instance_variables
Methods included from Assertions
#assert_valid_keys, #assert_valid_values
Methods included from DigestHelpers
Constructor Details
This class inherits a constructor from Turntabler::Resource
Instance Attribute Details
#about ⇒ String (readonly)
A brief description about the user
53 |
# File 'lib/turntabler/user.rb', line 53 attribute :about |
#acl ⇒ Fixnum (readonly)
The access control determining what is authorized
31 |
# File 'lib/turntabler/user.rb', line 31 attribute :acl |
#avatar ⇒ Turntabler::Avatar (readonly)
The user’s currently active avatar
65 66 67 |
# File 'lib/turntabler/user.rb', line 65 attribute :avatar, :avatarid do |value| Avatar.new(client, :_id => value) end |
#facebook_url ⇒ String (readonly)
This is only available if the user is connected to the authorized user through Facebook
The user’s unique identifier on Facebook
40 |
# File 'lib/turntabler/user.rb', line 40 attribute :facebook_url, :facebook |
#fans_count ⇒ Fixnum (readonly)
The number of fans this user has
35 |
# File 'lib/turntabler/user.rb', line 35 attribute :fans_count, :fans |
#hangout ⇒ String (readonly)
A description of the rooms on Turntable the user likes to hang out
61 |
# File 'lib/turntabler/user.rb', line 61 attribute :hangout |
#id ⇒ String (readonly)
Allow the id to be set via the “userid” attribute
11 |
# File 'lib/turntabler/user.rb', line 11 attribute :id, :userid, :load => false |
#laptop_name ⇒ String (readonly)
The name of the laptop the DJ uses
19 |
# File 'lib/turntabler/user.rb', line 19 attribute :laptop_name, :laptop |
#laptop_version ⇒ String (readonly)
The version # for the laptop
23 |
# File 'lib/turntabler/user.rb', line 23 attribute :laptop_version |
#name ⇒ String (readonly)
The DJ name for this user
15 |
# File 'lib/turntabler/user.rb', line 15 attribute :name, :name, :username |
#points ⇒ Fixnum (readonly)
The total number of points accumulated all-time
27 |
# File 'lib/turntabler/user.rb', line 27 attribute :points |
#sticker_placements(reload = false) ⇒ Array<Turntabler::StickerPlacement> (readonly)
Gets the stickers that are currently placed on the user’s laptop.
71 72 73 74 |
# File 'lib/turntabler/user.rb', line 71 attribute :sticker_placements, :sticker_placements, :placements do |placements| placements = placements.keys if placements.is_a?(Hash) placements.map {|attrs| StickerPlacement.new(client, attrs)} end |
#top_artists ⇒ String (readonly)
The user’s favorite artists
57 |
# File 'lib/turntabler/user.rb', line 57 attribute :top_artists, :topartists |
#twitter_id ⇒ String (readonly)
This is only available if the user is connected to the authorized user through Twitter
The user’s unique identifier on Twitter
45 |
# File 'lib/turntabler/user.rb', line 45 attribute :twitter_id, :twitter, :twitterid_lower |
#website ⇒ String (readonly)
The user’s personal website
49 |
# File 'lib/turntabler/user.rb', line 49 attribute :website |
Instance Method Details
#add_as_moderator ⇒ Object
Adds the user as a moderator in the current room.
user.add_as_moderator # => true
199 200 201 202 |
# File 'lib/turntabler/user.rb', line 199 def add_as_moderator api('room.add_moderator', :roomid => room.id, :section => room.section, :target_userid => id) true end |
#become_fan ⇒ true
Marks the current user as a fan of this user.
119 120 121 122 |
# File 'lib/turntabler/user.rb', line 119 def become_fan api('user.become_fan', :djid => id) true end |
#block ⇒ true
Blocks this user from being able to send private messages.
235 236 237 238 |
# File 'lib/turntabler/user.rb', line 235 def block api('block.add', :blockedid => id) true end |
#boot(reason = '') ⇒ true
Boots the user for the specified reason.
258 259 260 261 |
# File 'lib/turntabler/user.rb', line 258 def boot(reason = '') api('room.boot_user', :roomid => room.id, :section => room.section, :target_userid => id, :reason => reason) true end |
#dj? ⇒ Boolean
Is the user currently DJing in the room?
172 173 174 |
# File 'lib/turntabler/user.rb', line 172 def dj? !room.dj(id).nil? end |
#listener? ⇒ Boolean
Is the user currently a listener in the room?
163 164 165 |
# File 'lib/turntabler/user.rb', line 163 def listener? !room.listener(id).nil? end |
#load ⇒ true
Loads the attributes for this user. Attributes will automatically load when accessed, but this allows data to be forcefully loaded upfront.
84 85 86 87 88 |
# File 'lib/turntabler/user.rb', line 84 def load data = api('user.get_profile', :userid => id) self.attributes = data super end |
#messages ⇒ Array<Turntabler::Message>
Gets the private conversation history with this user.
153 154 155 156 |
# File 'lib/turntabler/user.rb', line 153 def data = api('pm.history', :receiverid => id) data['history'].map {|attrs| Message.new(client, attrs)} end |
#moderator? ⇒ Boolean
Is the user currently a moderator for the room?
192 193 194 |
# File 'lib/turntabler/user.rb', line 192 def moderator? !room.moderator(id).nil? end |
#presence ⇒ String
Gets the availability status for this user.
96 97 98 99 |
# File 'lib/turntabler/user.rb', line 96 def presence data = api('presence.get', :uid => id) data['presence']['status'] end |
#remove_as_dj ⇒ true
Stops the user from DJing.
182 183 184 185 |
# File 'lib/turntabler/user.rb', line 182 def remove_as_dj api('room.rem_dj', :roomid => room.id, :section => room.section, :djid => id) true end |
#remove_as_moderator ⇒ true
Removes the user from being a moderator in the current room.
210 211 212 213 |
# File 'lib/turntabler/user.rb', line 210 def remove_as_moderator api('room.rem_moderator', :roomid => room.id, :section => room.section, :target_userid => id) true end |
#report(reason = '') ⇒ true
Reports abuse by a user.
270 271 272 273 |
# File 'lib/turntabler/user.rb', line 270 def report(reason = '') api('room.report_user', :roomid => room.id, :section => room.section, :reported => id, :reason => reason) true end |
#say(content) ⇒ true
Sends a private message to this user.
142 143 144 145 |
# File 'lib/turntabler/user.rb', line 142 def say(content) api('pm.send', :receiverid => id, :text => content) true end |
#stalk ⇒ Turntabler::Room
This will make the current user a fan of this user
Gets the location of the user.
222 223 224 225 226 227 |
# File 'lib/turntabler/user.rb', line 222 def stalk become_fan unless client.user.fan_of.include?(self) client.rooms.with_friends.detect do |room| room.listener(id) end end |
#unblock ⇒ true
Unblocks this user from being able to send private messages.
246 247 248 249 |
# File 'lib/turntabler/user.rb', line 246 def unblock api('block.remove', :blockedid => id) true end |
#unfan ⇒ true
Marks the current user no longer as a fan of this user.
130 131 132 133 |
# File 'lib/turntabler/user.rb', line 130 def unfan api('user.remove_fan', :djid => id) true end |