Class: Rublox::Presence
- Inherits:
-
Object
- Object
- Rublox::Presence
- Defined in:
- lib/rublox/models/presence.rb
Overview
This class is handled internally by the public interface such as Client#user_presence_from_id. You should not be creating it yourself.
The Presence class corresponds to a response you can get via presence.roblox.com/v1/presence/users. You can use it to get information about the presence states of users.
Instance Attribute Summary collapse
-
#game_job_id ⇒ String?
readonly
randomly generated string with hexadecimal numbers containing the server’s job ID (which looks like “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”), it can be also accessed in-game via the game.JobId property.
-
#last_online_date ⇒ Time
readonly
The date at which the user was last online.
-
#last_presence_type ⇒ PresenceType
readonly
The last presence type of the user.
-
#presence_type ⇒ PresenceType
readonly
The current presence type.
Instance Method Summary collapse
-
#initialize(data, client) ⇒ Presence
constructor
A new instance of Presence.
-
#place ⇒ Place?
The place last visited by the user, can be nil if the user has never played a game.
-
#root_place ⇒ Place?
The root of the place last visited by the user, can be nil if the user has never played a game.
-
#universe ⇒ Universe?
The universe of the place last visited by the user, can be nil if the user has never played a game.
-
#user ⇒ FullUser
The user tied to the presence.
Constructor Details
#initialize(data, client) ⇒ Presence
Returns a new instance of Presence.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rublox/models/presence.rb', line 59 def initialize(data, client) @presence_type = PresenceType.enum_to_presence_type(data["userPresenceType"]) @last_location = data["lastLocation"] @place_id = data["placeId"] @root_place_id = data["rootPlaceId"] @game_job_id = data["gameId"] @universe_id = data["universeId"] @user_id = data["userId"] @last_online_date = Time.iso8601(data["lastOnline"]) @client = client end |
Instance Attribute Details
#game_job_id ⇒ String? (readonly)
Unlike it sounds, this is not a numerical ID like of a user. It’s a
randomly generated string with hexadecimal numbers containing the server’s job ID (which looks like “XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX”), it can be also accessed in-game via the game.JobId property.
54 55 56 |
# File 'lib/rublox/models/presence.rb', line 54 def game_job_id @game_job_id end |
#last_online_date ⇒ Time (readonly)
Returns the date at which the user was last online.
57 58 59 |
# File 'lib/rublox/models/presence.rb', line 57 def last_online_date @last_online_date end |
#last_presence_type ⇒ PresenceType (readonly)
Returns the last presence type of the user.
47 48 49 |
# File 'lib/rublox/models/presence.rb', line 47 def last_presence_type @last_presence_type end |
#presence_type ⇒ PresenceType (readonly)
Returns the current presence type.
44 45 46 |
# File 'lib/rublox/models/presence.rb', line 44 def presence_type @presence_type end |
Instance Method Details
#place ⇒ Place?
add Place class
Returns the place last visited by the user, can be nil if the user has never played a game.
75 76 77 |
# File 'lib/rublox/models/presence.rb', line 75 def place return unless @place_id end |
#root_place ⇒ Place?
add Place class
Returns the root of the place last visited by the user, can be nil if the user has never played a game.
82 83 84 |
# File 'lib/rublox/models/presence.rb', line 82 def root_place return unless @root_place_id end |
#universe ⇒ Universe?
add Universe class
Returns the universe of the place last visited by the user, can be nil if the user has never played a game.
89 90 91 |
# File 'lib/rublox/models/presence.rb', line 89 def universe return unless @universe_id end |
#user ⇒ FullUser
Returns the user tied to the presence.
94 95 96 |
# File 'lib/rublox/models/presence.rb', line 94 def user @client.user_from_id(@user_id) end |