Class: SteamPlayer
- Inherits:
-
Object
- Object
- SteamPlayer
- Defined in:
- lib/steam/steam_player.rb
Overview
The SteamPlayer class represents a player connected to a server
Instance Attribute Summary collapse
-
#client_port ⇒ Object
readonly
Returns the value of attribute client_port.
-
#connect_time ⇒ Object
readonly
Returns the value of attribute connect_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#loss ⇒ Object
readonly
Returns the value of attribute loss.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ping ⇒ Object
readonly
Returns the value of attribute ping.
-
#real_id ⇒ Object
readonly
Returns the value of attribute real_id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#steam_id ⇒ Object
readonly
Returns the value of attribute steam_id.
Instance Method Summary collapse
-
#add_info(real_id, name, steam_id, *player_data) ⇒ Object
Extends this player object with additional information acquired using RCON status.
-
#initialize(id, name, score, connect_time) ⇒ SteamPlayer
constructor
Creates a new SteamPlayer object based on the given information.
-
#to_s ⇒ Object
Returns a String representation of this player.
Constructor Details
#initialize(id, name, score, connect_time) ⇒ SteamPlayer
Creates a new SteamPlayer object based on the given information
15 16 17 18 19 20 21 |
# File 'lib/steam/steam_player.rb', line 15 def initialize(id, name, score, connect_time) @connect_time = connect_time @id = id @name = name @score = score @extended = false end |
Instance Attribute Details
#client_port ⇒ Object (readonly)
Returns the value of attribute client_port.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def client_port @client_port end |
#connect_time ⇒ Object (readonly)
Returns the value of attribute connect_time.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def connect_time @connect_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def id @id end |
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def ip_address @ip_address end |
#loss ⇒ Object (readonly)
Returns the value of attribute loss.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def loss @loss end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def name @name end |
#ping ⇒ Object (readonly)
Returns the value of attribute ping.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def ping @ping end |
#real_id ⇒ Object (readonly)
Returns the value of attribute real_id.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def real_id @real_id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def score @score end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def state @state end |
#steam_id ⇒ Object (readonly)
Returns the value of attribute steam_id.
11 12 13 |
# File 'lib/steam/steam_player.rb', line 11 def steam_id @steam_id end |
Instance Method Details
#add_info(real_id, name, steam_id, *player_data) ⇒ Object
Extends this player object with additional information acquired using RCON status
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/steam/steam_player.rb', line 25 def add_info(real_id, name, steam_id, *player_data) @extended = true unless name == @name raise SteamCondenserException.new('Information to add belongs to a different player.') end @real_id = real_id @steam_id = steam_id if steam_id == 'BOT' @state = player_data[0] else @ip_address, @client_port = player_data[4].split(':') @loss = player_data[2] @ping = player_data[1] @state = player_data[3] end end |
#to_s ⇒ Object
Returns a String representation of this player
45 46 47 48 49 50 51 |
# File 'lib/steam/steam_player.rb', line 45 def to_s if @extended "\##{@real_id} \"#{@name}\", SteamID: #{@steam_id}, Score: #{@score}, Time: #{@connect_time}" else "\##{@id} \"#{@name}\", Score: #{@score}, Time: #{@connect_time}" end end |