Class: Lapis::Yggdrasil::Profile
- Inherits:
-
Object
- Object
- Lapis::Yggdrasil::Profile
- Defined in:
- lib/lapis/yggdrasil/profile.rb
Overview
Player information associated with a game.
Instance Attribute Summary collapse
-
#id ⇒ Uuid
readonly
Unique ID of the profile.
- #legacy? ⇒ Boolean readonly
-
#name ⇒ String
readonly
Displayed player name.
Class Method Summary collapse
-
.from_properties(properties) ⇒ Profile
Creates a profile from a set of properties in a response.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Compares the profile to another.
-
#initialize(id, name, is_legacy = false) ⇒ Profile
constructor
Creates a player profile.
Constructor Details
#initialize(id, name, is_legacy = false) ⇒ Profile
Creates a player profile.
29 30 31 32 33 |
# File 'lib/lapis/yggdrasil/profile.rb', line 29 def initialize(id, name, is_legacy = false) @id = id @name = name.dup.freeze @is_legacy = !!is_legacy end |
Instance Attribute Details
#id ⇒ Uuid (readonly)
Unique ID of the profile.
11 12 13 |
# File 'lib/lapis/yggdrasil/profile.rb', line 11 def id @id end |
#legacy? ⇒ Boolean (readonly)
21 22 23 |
# File 'lib/lapis/yggdrasil/profile.rb', line 21 def legacy? @is_legacy end |
#name ⇒ String (readonly)
Displayed player name.
15 16 17 |
# File 'lib/lapis/yggdrasil/profile.rb', line 15 def name @name end |
Class Method Details
.from_properties(properties) ⇒ Profile
Creates a profile from a set of properties in a response.
52 53 54 55 56 57 58 59 60 |
# File 'lib/lapis/yggdrasil/profile.rb', line 52 def self.from_properties(properties) fail ArgumentError, 'ID is required' unless properties.key?(:id) fail ArgumentError, 'Name is required' unless properties.key?(:name) id = Lapis::Uuid.parse(properties[:id]) name = properties[:name] is_legacy = (properties.key?(:legacy) && properties[:legacy] == 'true') new(id, name, is_legacy) end |
Instance Method Details
#==(other) ⇒ true, false
Compares the profile to another.
39 40 41 42 43 |
# File 'lib/lapis/yggdrasil/profile.rb', line 39 def ==(other) other.id == @id && other.name == @name && other.legacy? == @is_legacy end |