Class: TTY::System

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/system.rb,
lib/tty/system/which.rb,
lib/tty/system/editor.rb

Defined Under Namespace

Classes: Editor, Which

Class Method Summary collapse

Class Method Details

.editorTTY::System::Editor

Proxy to editor object

Returns:



50
51
52
# File 'lib/tty/system.rb', line 50

def self.editor
  TTY::System::Editor
end

.exists?(name) ⇒ Boolean

Check if command is available

Parameters:

  • name (String)

    the command name

Returns:

  • (Boolean)


41
42
43
# File 'lib/tty/system.rb', line 41

def self.exists?(name)
  !!self.which(name)
end

.unix?Boolean

Check if unix platform

Returns:

  • (Boolean)


22
23
24
# File 'lib/tty/system.rb', line 22

def self.unix?
  RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
end

.which(command) ⇒ Object

Find an executable in the PATH

See Also:



31
32
33
# File 'lib/tty/system.rb', line 31

def self.which(command)
  Which.new(command).which
end

.windows?Boolean

Check if windows platform.

Returns:

  • (Boolean)


13
14
15
# File 'lib/tty/system.rb', line 13

def self.windows?
  RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw|windows/
end