Class: EME::TeraServer::Server

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#crowdObject (readonly)

Returns the value of attribute crowd.



2
3
4
# File 'lib/eme/tera_server/server.rb', line 2

def crowd
  @crowd
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/eme/tera_server/server.rb', line 2

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



2
3
4
# File 'lib/eme/tera_server/server.rb', line 2

def kind
  @kind
end

#messageObject (readonly)

Returns the value of attribute message.



2
3
4
# File 'lib/eme/tera_server/server.rb', line 2

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/eme/tera_server/server.rb', line 2

def name
  @name
end

#openObject (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

#abbrObject



13
14
15
# File 'lib/eme/tera_server/server.rb', line 13

def abbr
  return EME::TeraServer::Server.abbr(self.name)
end

#down?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/eme/tera_server/server.rb', line 31

def down?
  @status_flag.to_i(16) > 0x100
end

#maintenance?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/eme/tera_server/server.rb', line 23

def maintenance?
  @status_flag.to_i(16) == 0x100
end

#statusObject



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

Returns:

  • (Boolean)


27
28
29
# File 'lib/eme/tera_server/server.rb', line 27

def up?
  @status_flag.to_i(16) < 0x100
end