Module: BrowserGui

Defined in:
lib/browser_gui.rb,
lib/browser_gui/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.open_browser(url) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/browser_gui.rb', line 9

def self.open_browser(url)
  command = case RbConfig::CONFIG['host_os']
    when /mswin|mingw|cygwin/ then "start '#{url}'"
    when /darwin/ then "open '#{url}'"
    when /linux/ then "xdg-open '#{url}'"
  end
  # Spawn a process and return without waiting for it. Sleep 1 second to give Sinatra time to start up.
  command = "sleep 1; #{command}"
  pid = spawn(command)
  Process.detach(pid)
end