Module: Cri::Platform
- Defined in:
- lib/cri/platform.rb
Class Method Summary (collapse)
-
+ (Boolean) color?(io)
Checks whether colors can be enabled.
-
+ (Boolean) windows?
otherwise.
Class Method Details
+ (Boolean) color?(io)
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.
18 19 20 21 22 23 24 25 26 |
# File 'lib/cri/platform.rb', line 18 def self.color?(io) if !io.tty? false elsif windows? defined?(::Win32::Console::ANSI) else true end end |
+ (Boolean) windows?
otherwise.
9 10 11 |
# File 'lib/cri/platform.rb', line 9 def self.windows? !!(RUBY_PLATFORM =~ /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i) end |