Class: Vapor::Server
- Inherits:
-
Thor
- Object
- Thor
- Vapor::Server
- Defined in:
- lib/vapor.rb
Instance Method Summary collapse
- #add(handle, ip, port = 27015) ⇒ Object
- #connect(handle) ⇒ Object
- #info(handle = nil) ⇒ Object
-
#initialize(*args) ⇒ Server
constructor
A new instance of Server.
- #list ⇒ Object
- #rm(handle) ⇒ Object
Constructor Details
Instance Method Details
#add(handle, ip, port = 27015) ⇒ Object
39 40 41 |
# File 'lib/vapor.rb', line 39 def add(handle, ip, port=27015) @config.add_server(handle, ip, port) end |
#connect(handle) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vapor.rb', line 51 def connect(handle) s = @config.lookup_server_by_handle(handle) uri = "steam://connect/#{s['ip']}:#{s['port']}" if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ system "start #{uri}" elsif RbConfig::CONFIG['host_os'] =~ /darwin/ system "open #{uri}" elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ system "xdg-open #{uri}" end end |
#info(handle = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vapor.rb', line 18 def info(handle=nil) if ([:ip]) parts = [:ip].strip.split(':') ip = parts[0] port = parts[1] else s = @config.lookup_server_by_handle(handle) ip = s['ip'] port = s['port'] end Steam.server_info(ip, port) end |
#list ⇒ Object
33 34 35 |
# File 'lib/vapor.rb', line 33 def list Steam.server_listing(@config.data['servers']) end |
#rm(handle) ⇒ Object
45 46 47 |
# File 'lib/vapor.rb', line 45 def rm(handle) @config.rm_server(handle) end |