Class: DuckTest::Platforms::OSHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/duck_test/platforms/os_helper.rb

Overview

Methods used to determine the current operating system platform.

Class Method Summary (collapse)

Class Method Details

+ (Boolean) available?

Determines if a native listener is available for the current platform.

Returns:

  • (Boolean)

    Returns true if the listener is available.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/duck_test/platforms/os_helper.rb', line 67

def self.available?
  if self.is_linux?
    return Platforms::Linux::Listener.available?

  elsif self.is_mac?
    return Platforms::Mac::Listener.available?

  elsif self.is_windows?
    return Platforms::Windows::Listener.available?

  end

  return false
end

+ (Symbol) current_os

Returns a Symbol indicating the current operating system.

Currently returns one of four possible values:

:linux
:mac
:windows
:unknown

Returns:

  • (Symbol)


92
93
94
95
96
97
# File 'lib/duck_test/platforms/os_helper.rb', line 92

def self.current_os
  return :linux if self.is_linux?
  return :mac if self.is_mac?
  return :windows if self.is_windows?
  return :unknown
end

+ (Boolean) is_linux?

Determines if the current operating system is: Linux

Returns:

  • (Boolean)

    Returns true if the current operating system is: Linux



46
47
48
# File 'lib/duck_test/platforms/os_helper.rb', line 46

def self.is_linux?
  RUBY_PLATFORM =~ /linux/i
end

+ (Boolean) is_mac?

Determines if the current operating system is: Macintosh

Returns:

  • (Boolean)

    Returns true if the current operating system is: Macintosh



53
54
55
# File 'lib/duck_test/platforms/os_helper.rb', line 53

def self.is_mac?
  RUBY_PLATFORM =~ /darwin/i
end

+ (Boolean) is_windows?

Determines if the current operating system is: Windoze

Returns:

  • (Boolean)

    Returns true if the current operating system is: Windoze



60
61
62
# File 'lib/duck_test/platforms/os_helper.rb', line 60

def self.is_windows?
  RUBY_PLATFORM =~ /mswin|mingw/i
end