Module: Platform

Defined in:
lib/platform.rb

Overview

vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab

Class Method Summary collapse

Class Method Details

.is_darwinObject



12
13
14
# File 'lib/platform.rb', line 12

def self.is_darwin
	!RUBY_PLATFORM.match("darwin").nil?
end

.is_linuxObject



8
9
10
# File 'lib/platform.rb', line 8

def self.is_linux
	!RUBY_PLATFORM.match("linux").nil?
end

.is_nixObject



4
5
6
# File 'lib/platform.rb', line 4

def self.is_nix
	!RUBY_PLATFORM.match("linux|darwin").nil?
end

.open(path) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/platform.rb', line 16

def self.open(path)
	command = "start #{path}"
	if self.is_linux
		command = "xdg-open #{path}"
	elsif self.is_darwin
		command = "open #{path}"
	end
	sh command
end

.runtime(cmd, runtime = 'v4.0.30319') ⇒ Object



40
41
42
43
44
45
46
# File 'lib/platform.rb', line 40

def self.runtime(cmd, runtime='v4.0.30319')
	command = cmd
	if self.is_nix
		command = "mono --runtime=#{runtime} #{cmd}"
	end
	command
end

.start(command) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/platform.rb', line 30

def self.start(command)
	if self.is_linux
		command = "xterm -e '#{command}'"
	elsif self.is_darwin
		command = "Terminal -e '#{command}'"
	else
		command = "start #{command}"
	end
end

.switch(arg) ⇒ Object



48
49
50
51
# File 'lib/platform.rb', line 48

def self.switch(arg)
	sw = self.is_nix ? " -" : " /"
	sw + arg
end