Class: Rubycon::ServerInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycon/server_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ ServerInfo

Returns a new instance of ServerInfo.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubycon/server_info.rb', line 5

def initialize(server)
  begin
    conn = SourceServer.new server.address, server.port
    @ping = conn.ping.round(0)
    @players_count = conn.server_info[:number_of_players]
    @players_max = conn.server_info[:max_players]
    @map = conn.server_info[:map_name]
    @name = conn.server_info[:server_name]
    @reachable = true
  rescue
    @reachable = false
  end
end

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



3
4
5
# File 'lib/rubycon/server_info.rb', line 3

def map
  @map
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rubycon/server_info.rb', line 3

def name
  @name
end

#pingObject (readonly)

Returns the value of attribute ping.



3
4
5
# File 'lib/rubycon/server_info.rb', line 3

def ping
  @ping
end

#players_countObject (readonly)

Returns the value of attribute players_count.



3
4
5
# File 'lib/rubycon/server_info.rb', line 3

def players_count
  @players_count
end

#players_maxObject (readonly)

Returns the value of attribute players_max.



3
4
5
# File 'lib/rubycon/server_info.rb', line 3

def players_max
  @players_max
end

Instance Method Details

#reachable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rubycon/server_info.rb', line 19

def reachable?
  @reachable
end