Class: Arkrb::Server
- Inherits:
-
Object
- Object
- Arkrb::Server
- Defined in:
- lib/arkrb/server.rb
Instance Attribute Summary collapse
-
#instance_name ⇒ Object
readonly
Returns the value of attribute instance_name.
-
#mod_list ⇒ Object
readonly
Returns the value of attribute mod_list.
Instance Method Summary collapse
- #backup! ⇒ True, Exception
- #broadcast(message) ⇒ True, Exception
- #disable_mod(mod_id) ⇒ True, Exception
- #enable_mod(mod_id) ⇒ True, Exception
- #get_player_list ⇒ Object
-
#initialize(instance_name, sanitize_output = true) ⇒ Server
constructor
A new instance of Server.
- #install ⇒ Object
- #install_mod(mod_id) ⇒ True, Exception
- #mod_updates_available? ⇒ Boolean
- #rcon_cmd(command) ⇒ Object
- #reinstall_mod(mod_id) ⇒ True, Exception
- #restart! ⇒ True, Exception
- #save_world! ⇒ True, Exception
- #start!(verbose = false) ⇒ True, Exception
- #status! ⇒ Object
- #stop! ⇒ True, Exception
- #uninstall_mod(mod_id) ⇒ True, Exception
- #update! ⇒ True, Exception
- #update_available? ⇒ Boolean
Constructor Details
#initialize(instance_name, sanitize_output = true) ⇒ Server
Returns a new instance of Server.
11 12 13 14 15 |
# File 'lib/arkrb/server.rb', line 11 def initialize(instance_name, sanitize_output = true) @instance_name = instance_name @sanitize_output = sanitize_output mod_list end |
Instance Attribute Details
#instance_name ⇒ Object (readonly)
Returns the value of attribute instance_name.
17 18 19 |
# File 'lib/arkrb/server.rb', line 17 def instance_name @instance_name end |
#mod_list ⇒ Object (readonly)
Returns the value of attribute mod_list.
17 18 19 |
# File 'lib/arkrb/server.rb', line 17 def mod_list @mod_list end |
Instance Method Details
#backup! ⇒ True, Exception
48 49 50 |
# File 'lib/arkrb/server.rb', line 48 def backup! arkmanager_exec :backup end |
#broadcast(message) ⇒ True, Exception
83 84 85 |
# File 'lib/arkrb/server.rb', line 83 def broadcast() arkmanager_exec(:broadcast, ) end |
#disable_mod(mod_id) ⇒ True, Exception
63 64 65 |
# File 'lib/arkrb/server.rb', line 63 def disable_mod(mod_id) arkmanager_exec(:disable_mod, mod_id) end |
#enable_mod(mod_id) ⇒ True, Exception
58 59 60 |
# File 'lib/arkrb/server.rb', line 58 def enable_mod(mod_id) arkmanager_exec(:enable_mod, mod_id) end |
#get_player_list ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/arkrb/server.rb', line 92 def get_player_list sanitize_filter = @sanitize_output @sanitize_output = true users = [] player_list = rcon_cmd('ListPlayers') .split("\n") .map {|m| m.delete('\\"').strip} .reject(&:empty?) player_list.delete_if {|x| x =~ /Running command/im} if player_list.count == 1 && player_list.first =~ /no/im users << Player.new(player_list.first, player_list.first, player_list.first) else player_list.map! {|p| %i(name steam_id).zip(p.gsub!(/^[0-9]+. /im, '').split(', ')).to_h} player_list.each do |u| player_id = rcon_cmd("GetPlayerIDForSteamID #{u[:steam_id].to_i}") .split("\n") .delete_if {|x| x =~ /Running command/im} .map! {|x| x.delete('\\"').strip} .reject(&:empty?) .first.split('PlayerID: ').last users << Player.new(u[:name], u[:steam_id], player_id) end end @sanitize_output = sanitize_filter users end |
#install ⇒ Object
19 20 21 |
# File 'lib/arkrb/server.rb', line 19 def install arkmanager_exec :install end |
#install_mod(mod_id) ⇒ True, Exception
68 69 70 |
# File 'lib/arkrb/server.rb', line 68 def install_mod(mod_id) arkmanager_exec(:install_mod, mod_id) end |
#mod_updates_available? ⇒ Boolean
125 126 127 |
# File 'lib/arkrb/server.rb', line 125 def mod_updates_available? arkmanager_exec :check_mod_update end |
#rcon_cmd(command) ⇒ Object
88 89 90 |
# File 'lib/arkrb/server.rb', line 88 def rcon_cmd(command) arkmanager_exec(:rconcmd, command.to_s) end |
#reinstall_mod(mod_id) ⇒ True, Exception
78 79 80 |
# File 'lib/arkrb/server.rb', line 78 def reinstall_mod(mod_id) arkmanager_exec(:reinstall_mod, mod_id) end |
#restart! ⇒ True, Exception
34 35 36 |
# File 'lib/arkrb/server.rb', line 34 def restart! arkmanager_exec :restart end |
#save_world! ⇒ True, Exception
53 54 55 |
# File 'lib/arkrb/server.rb', line 53 def save_world! arkmanager_exec :save_world end |
#start!(verbose = false) ⇒ True, Exception
24 25 26 |
# File 'lib/arkrb/server.rb', line 24 def start!(verbose = false) arkmanager_exec :start end |
#status! ⇒ Object
38 39 40 |
# File 'lib/arkrb/server.rb', line 38 def status! arkmanager_exec :status end |
#stop! ⇒ True, Exception
29 30 31 |
# File 'lib/arkrb/server.rb', line 29 def stop! arkmanager_exec :stop end |
#uninstall_mod(mod_id) ⇒ True, Exception
73 74 75 |
# File 'lib/arkrb/server.rb', line 73 def uninstall_mod(mod_id) arkmanager_exec(:uninstall_mod, mod_id) end |
#update! ⇒ True, Exception
43 44 45 |
# File 'lib/arkrb/server.rb', line 43 def update! arkmanager_exec :update end |
#update_available? ⇒ Boolean
120 121 122 |
# File 'lib/arkrb/server.rb', line 120 def update_available? arkmanager_exec :check_update end |