Class: EME::TeraServer::Server
- Inherits:
-
Object
- Object
- EME::TeraServer::Server
- Defined in:
- lib/eme/tera_server/server.rb
Constant Summary collapse
- PRESET_ABBR =
{"Highwatch" => 'HW', "Lake of Tears" => "LT", "Valley of Titans" => "VT", "New Pora" => "PA"}.freeze
Instance Attribute Summary collapse
-
#crowd ⇒ Object
readonly
Returns the value of attribute crowd.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#open ⇒ Object
readonly
Returns the value of attribute open.
Class Method Summary collapse
Instance Method Summary collapse
- #abbr ⇒ Object
- #down? ⇒ Boolean
-
#initialize(opts) ⇒ Server
constructor
A new instance of Server.
- #maintenance? ⇒ Boolean
- #status ⇒ Object
- #up? ⇒ Boolean
Constructor Details
#initialize(opts) ⇒ Server
Returns a new instance of Server.
3 4 5 6 7 8 9 10 11 |
# File 'lib/eme/tera_server/server.rb', line 3 def initialize(opts) @name = opts[:name] @id = opts[:id].to_i @kind = opts[:kind] @status_flag = opts[:status_flag] @message = opts[:message] @crowd = opts[:crowd] @open = opts[:open] end |
Instance Attribute Details
#crowd ⇒ Object (readonly)
Returns the value of attribute crowd.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def crowd @crowd end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def kind @kind end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def name @name end |
#open ⇒ Object (readonly)
Returns the value of attribute open.
2 3 4 |
# File 'lib/eme/tera_server/server.rb', line 2 def open @open end |
Class Method Details
.abbr(server_name) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/eme/tera_server/server.rb', line 35 def self.abbr(server_name) return PRESET_ABBR[server_name] if PRESET_ABBR[server_name] tmp = server_name.split(' ') return(tmp[0][0] + tmp[1][0]).upcase if tmp.length > 1 (tmp[0][0] + tmp[0][1]).upcase end |
.server_id(server_name) ⇒ Object
43 44 45 |
# File 'lib/eme/tera_server/server.rb', line 43 def self.server_id(server_name) end |
Instance Method Details
#abbr ⇒ Object
13 14 15 |
# File 'lib/eme/tera_server/server.rb', line 13 def abbr return EME::TeraServer::Server.abbr(self.name) end |
#down? ⇒ Boolean
31 32 33 |
# File 'lib/eme/tera_server/server.rb', line 31 def down? @status_flag.to_i(16) > 0x100 end |
#maintenance? ⇒ Boolean
23 24 25 |
# File 'lib/eme/tera_server/server.rb', line 23 def maintenance? @status_flag.to_i(16) == 0x100 end |
#status ⇒ Object
17 18 19 20 21 |
# File 'lib/eme/tera_server/server.rb', line 17 def status return "Up" if up? return "Down" if down? return "Maintenance" end |
#up? ⇒ Boolean
27 28 29 |
# File 'lib/eme/tera_server/server.rb', line 27 def up? @status_flag.to_i(16) < 0x100 end |