Module: Cri::Platform Private

Defined in:
lib/cri/platform.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provides tools to detect platform and environment configuration (e.g. is color support available?)

Class Method Summary collapse

Class Method Details

.color?(io) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks whether colors can be enabled. For colors to be enabled, the given IO should be a TTY, and, when on Windows, ::Win32::Console::ANSI needs to be defined.

Returns:

  • (Boolean)

    True if colors should be enabled, false otherwise.



20
21
22
23
24
25
26
27
28
# File 'lib/cri/platform.rb', line 20

def self.color?(io)
  if !io.tty?
    false
  elsif windows?
    defined?(::Win32::Console::ANSI)
  else
    true
  end
end

.windows?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

otherwise.

Returns:

  • (Boolean)

    true if the current platform is Windows, false



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

def self.windows?
  RUBY_PLATFORM =~ /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
end