Class: Shop::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/shop/platform.rb

Instance Method Summary collapse

Instance Method Details

#darwin?Boolean

Public: tests if currently running on darwin.

Returns true if running on darwin (MacOS X), else false

Returns:

  • (Boolean)


10
11
12
# File 'lib/shop/platform.rb', line 10

def darwin?
  !!(RUBY_PLATFORM =~ /darwin/)
end

#open_commandObject

Public: returns the command used to open a file or URL for the current platform.

Currently only supports MacOS X and Linux with ‘xdg-open`.

Returns a String with the bin



29
30
31
32
33
34
35
36
37
# File 'lib/shop/platform.rb', line 29

def open_command
  if darwin?
    'open'
  elsif windows?
    'start'
  else
    'xdg-open'
  end
end

#windows?Boolean

Public: tests if currently running on windows.

Apparently Windows RUBY_PLATFORM can be ‘win32’ or ‘mingw32’

Returns true if running on windows (win32/mingw32), else false

Returns:

  • (Boolean)


19
20
21
# File 'lib/shop/platform.rb', line 19

def windows?
  !!(RUBY_PLATFORM =~ /mswin|mingw/)
end