Class: Rublox::Presence

Inherits:
Object
  • Object
show all
Defined in:
lib/rublox/models/presence.rb

Overview

Note:

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

Instance Method Summary collapse

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_idString? (readonly)

Note:

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.

Returns:

  • (String, nil)

    the job ID of the game last played by the user.



54
55
56
# File 'lib/rublox/models/presence.rb', line 54

def game_job_id
  @game_job_id
end

#last_online_dateTime (readonly)

Returns the date at which the user was last online.

Returns:

  • (Time)

    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_typePresenceType (readonly)

Returns the last presence type of the user.

Returns:



47
48
49
# File 'lib/rublox/models/presence.rb', line 47

def last_presence_type
  @last_presence_type
end

#presence_typePresenceType (readonly)

Returns the current presence type.

Returns:



44
45
46
# File 'lib/rublox/models/presence.rb', line 44

def presence_type
  @presence_type
end

Instance Method Details

#placePlace?

TODO:

add Place class

Returns the place last visited by the user, can be nil if the user has never played a game.

Returns:

  • (Place, nil)

    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_placePlace?

TODO:

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.

Returns:

  • (Place, nil)

    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

#universeUniverse?

TODO:

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.

Returns:

  • (Universe, nil)

    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

#userFullUser

Returns the user tied to the presence.

Returns:

  • (FullUser)

    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