Class: Vapor::Server

Inherits:
Thor
  • Object
show all
Defined in:
lib/vapor.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Server

Returns a new instance of Server.



10
11
12
13
# File 'lib/vapor.rb', line 10

def initialize(*args)
	super
	@config = STConfig.new
end

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 (options[:ip])
		parts = options[: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

#listObject



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