Module: Pry::Platform

Extended by:
Platform
Included in:
Helpers::BaseHelpers, Platform
Defined in:
lib/pry/platform.rb

Instance Method Summary collapse

Instance Method Details

#jruby?Boolean

Returns true when Pry is being run from JRuby.

Returns:

  • (Boolean)

    Returns true when Pry is being run from JRuby.



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

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

#jruby_19?Boolean

Returns true when Pry is being run from JRuby in 1.9 mode.

Returns:

  • (Boolean)

    Returns true when Pry is being run from JRuby in 1.9 mode.



58
59
60
# File 'lib/pry/platform.rb', line 58

def jruby_19?
  jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
end

#known_enginesObject

@return [Array] Returns an Array of Ruby engines that Pry is known to run on.



98
99
100
# File 'lib/pry/platform.rb', line 98

def known_engines
  [:jruby, :rbx, :mri]
end

#linux?Boolean

Note:

Queries RbConfig::CONFIG['host_os'] with a best guess.

Returns true if Pry is running on Linux.

Returns:

  • (Boolean)

    Returns true if Pry is running on Linux.



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

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

#mac_osx?Boolean

Note:

Queries RbConfig::CONFIG['host_os'] with a best guess.

Returns true if Pry is running on Mac OSX.

Returns:

  • (Boolean)

    Returns true if Pry is running on Mac OSX.



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

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

#mri?Boolean

Returns true when Pry is being run from MRI (CRuby).

Returns:

  • (Boolean)

    Returns true when Pry is being run from MRI (CRuby).



74
75
76
# File 'lib/pry/platform.rb', line 74

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

#mri_19?Boolean

Returns true when Pry is being run from MRI v1.9+ (CRuby).

Returns:

  • (Boolean)

    Returns true when Pry is being run from MRI v1.9+ (CRuby).



82
83
84
# File 'lib/pry/platform.rb', line 82

def mri_19?
  !!(mri? and RUBY_VERSION =~ /\A1\.9/)
end

#mri_2?Boolean

Returns true when Pry is being run from MRI v2+ (CRuby).

Returns:

  • (Boolean)

    Returns true when Pry is being run from MRI v2+ (CRuby).



90
91
92
# File 'lib/pry/platform.rb', line 90

def mri_2?
  !!(mri? and RUBY_VERSION =~ /\A2/)
end

#rbx?Boolean

Returns true when Pry is being run from Rubinius.

Returns:

  • (Boolean)

    Returns true when Pry is being run from Rubinius.



66
67
68
# File 'lib/pry/platform.rb', line 66

def rbx?
  RbConfig::CONFIG['ruby_install_name'] == 'rbx'
end

#windows?Boolean

Note:

Queries RbConfig::CONFIG['host_os'] with a best guess.

Returns true if Pry is running on Windows.

Returns:

  • (Boolean)

    Returns true if Pry is running on Windows.



33
34
35
# File 'lib/pry/platform.rb', line 33

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

#windows_ansi?Boolean

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

Returns:

  • (Boolean)

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



41
42
43
44
# File 'lib/pry/platform.rb', line 41

def windows_ansi?
  return false if not windows?
  !!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
end