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!(update_mods = false) ⇒ 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
52 53 54 |
# File 'lib/arkrb/server.rb', line 52 def backup! arkmanager_exec :backup end |
#broadcast(message) ⇒ True, Exception
87 88 89 |
# File 'lib/arkrb/server.rb', line 87 def broadcast() arkmanager_exec(:broadcast, ) end |
#disable_mod(mod_id) ⇒ True, Exception
67 68 69 |
# File 'lib/arkrb/server.rb', line 67 def disable_mod(mod_id) arkmanager_exec(:disable_mod, mod_id) end |
#enable_mod(mod_id) ⇒ True, Exception
62 63 64 |
# File 'lib/arkrb/server.rb', line 62 def enable_mod(mod_id) arkmanager_exec(:enable_mod, mod_id) end |
#get_player_list ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/arkrb/server.rb', line 96 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
72 73 74 |
# File 'lib/arkrb/server.rb', line 72 def install_mod(mod_id) arkmanager_exec(:install_mod, mod_id) end |
#mod_updates_available? ⇒ Boolean
129 130 131 |
# File 'lib/arkrb/server.rb', line 129 def mod_updates_available? arkmanager_exec :check_mod_update end |
#rcon_cmd(command) ⇒ Object
92 93 94 |
# File 'lib/arkrb/server.rb', line 92 def rcon_cmd(command) arkmanager_exec(:rconcmd, command.to_s) end |
#reinstall_mod(mod_id) ⇒ True, Exception
82 83 84 |
# File 'lib/arkrb/server.rb', line 82 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
57 58 59 |
# File 'lib/arkrb/server.rb', line 57 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
77 78 79 |
# File 'lib/arkrb/server.rb', line 77 def uninstall_mod(mod_id) arkmanager_exec(:uninstall_mod, mod_id) end |
#update!(update_mods = false) ⇒ True, Exception
43 44 45 46 47 48 49 |
# File 'lib/arkrb/server.rb', line 43 def update!(update_mods = false) if update_mods arkmanager_exec :update, '--update-mods' else arkmanager_exec :update end end |
#update_available? ⇒ Boolean
124 125 126 |
# File 'lib/arkrb/server.rb', line 124 def update_available? arkmanager_exec :check_update end |