Class: Lapis::Yggdrasil::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/lapis/yggdrasil/agent.rb

Overview

Information about the game to associate profiles with.

Constant Summary collapse

DEFAULT_AGENT =

Agent used for Minecraft.

Returns:

new('Minecraft', 1)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version) ⇒ Agent

Creates an agent.

Parameters:

  • name (String)

    Name of the game.

  • version (Fixnum)

    Client profile version.



19
20
21
22
# File 'lib/lapis/yggdrasil/agent.rb', line 19

def initialize(name, version)
  @name    = name.dup.freeze
  @version = version
end

Instance Attribute Details

#nameString (readonly)

Name of the game.

Returns:

  • (String)


9
10
11
# File 'lib/lapis/yggdrasil/agent.rb', line 9

def name
  @name
end

#versionFixnum (readonly)

Note:

This is always 1 right now, but may be increased in the future.

Client profile version.

Returns:

  • (Fixnum)


14
15
16
# File 'lib/lapis/yggdrasil/agent.rb', line 14

def version
  @version
end

Class Method Details

.from_properties(properties) ⇒ Agent

Note:

Missing properties will have their values pulled from DefaultAgent.

Creates an agent from a set of properties in a request.

Parameters:

  • properties (Hash<Symbol => String, Fixnum>)

    Set of properties.

Options Hash (properties):

  • :name (String)

    Name of the game.

  • :version (Fixnum)

    Client profile version.

Returns:



39
40
41
42
43
# File 'lib/lapis/yggdrasil/agent.rb', line 39

def self.from_properties(properties)
  name    = (properties[:name] || DEFAULT_AGENT.name).dup.freeze
  version = properties[:version] || DEFAULT_AGENT.version
  new(name, version)
end

Instance Method Details

#==(other) ⇒ true, false

Compares the agent to another.

Parameters:

  • other (Agent)

    Agent to compare against.

Returns:

  • (true)

    The agents are the same.

  • (false)

    The agents are different.



28
29
30
31
# File 'lib/lapis/yggdrasil/agent.rb', line 28

def ==(other)
  other.name == @name &&
      other.version == @version
end