Class: Rubycon::ServerInfo
- Inherits:
-
Object
- Object
- Rubycon::ServerInfo
- Defined in:
- lib/rubycon/server_info.rb
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ping ⇒ Object
readonly
Returns the value of attribute ping.
-
#players_count ⇒ Object
readonly
Returns the value of attribute players_count.
-
#players_max ⇒ Object
readonly
Returns the value of attribute players_max.
Instance Method Summary collapse
-
#initialize(server) ⇒ ServerInfo
constructor
A new instance of ServerInfo.
- #reachable? ⇒ Boolean
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
#map ⇒ Object (readonly)
Returns the value of attribute map.
3 4 5 |
# File 'lib/rubycon/server_info.rb', line 3 def map @map end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rubycon/server_info.rb', line 3 def name @name end |
#ping ⇒ Object (readonly)
Returns the value of attribute ping.
3 4 5 |
# File 'lib/rubycon/server_info.rb', line 3 def ping @ping end |
#players_count ⇒ Object (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_max ⇒ Object (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
19 20 21 |
# File 'lib/rubycon/server_info.rb', line 19 def reachable? @reachable end |