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:



58
59
60
# File 'lib/tty/system.rb', line 58

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

.exists?(name) ⇒ Boolean

Check if command is available

Parameters:

  • name (String)

    the command name

Returns:

  • (Boolean)


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

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

.match_os?(matcher) ⇒ Boolean

Check if platform matches given systems

Returns:

  • (Boolean)


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

def self.match_os?(matcher)
  !!(RbConfig::CONFIG['host_os'] =~ matcher)
end

.unix?Boolean

Check if unix platform

Returns:

  • (Boolean)


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

def self.unix?
  match_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:



39
40
41
# File 'lib/tty/system.rb', line 39

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

.windows?Boolean

Check if windows platform.

Returns:

  • (Boolean)


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

def self.windows?
  match_os?(/msdos|mswin|djgpp|mingw|windows/i)
end