Module: Pry::Helpers::Platform

Defined in:
lib/pry/helpers/platform.rb

Overview

Contains methods for querying the platform that Pry is running on

Since:

  • v0.12.0

Class Method Summary collapse

Class Method Details

.jruby?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



35
36
37
# File 'lib/pry/helpers/platform.rb', line 35

def self.jruby?
  RbConfig::CONFIG['ruby_install_name'] == 'jruby'
end

.jruby_19?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



40
41
42
# File 'lib/pry/helpers/platform.rb', line 40

def self.jruby_19?
  jruby? && RbConfig::CONFIG['ruby_version'] == '1.9'
end

.linux?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



17
18
19
# File 'lib/pry/helpers/platform.rb', line 17

def self.linux?
  !!(RbConfig::CONFIG['host_os'] =~ /linux/i)
end

.mac_osx?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



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

def self.mac_osx?
  !!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i)
end

.mri?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



45
46
47
# File 'lib/pry/helpers/platform.rb', line 45

def self.mri?
  RbConfig::CONFIG['ruby_install_name'] == 'ruby'
end

.mri_19?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



50
51
52
# File 'lib/pry/helpers/platform.rb', line 50

def self.mri_19?
  mri? && RUBY_VERSION.start_with?('1.9')
end

.mri_2?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



55
56
57
# File 'lib/pry/helpers/platform.rb', line 55

def self.mri_2?
  mri? && RUBY_VERSION.start_with?('2')
end

.windows?Boolean

Returns true when Pry is running on Windows with ANSI support, false otherwise.

Returns:

  • (Boolean)

    true when Pry is running on Windows with ANSI support, false otherwise

Since:

  • v0.12.0



23
24
25
# File 'lib/pry/helpers/platform.rb', line 23

def self.windows?
  !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
end

.windows_ansi?Boolean

Returns:

  • (Boolean)

Since:

  • v0.12.0



28
29
30
31
32
# File 'lib/pry/helpers/platform.rb', line 28

def self.windows_ansi?
  return false unless windows?

  !!(defined?(Win32::Console) || Pry::Env['ANSICON'] || mri_2?)
end