Module: Morpheus::Util
- Defined in:
- lib/morpheus/util.rb
Overview
Provides global utility methods Such as opening a web browser to a url
Class Method Summary collapse
Class Method Details
.open_url(url) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/morpheus/util.rb', line 20 def self.open_url(url) cmd = open_url_command(url) result = system(cmd) if result return 0, nil else return $?.exitstatus, "system command '#{cmd}' exited non-zero" end end |
.open_url_command(url) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/morpheus/util.rb', line 6 def self.open_url_command(url) cmd = nil if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ cmd = "start #{url}" elsif RbConfig::CONFIG['host_os'] =~ /darwin/ cmd = "open #{url}" elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ cmd = "xdg-open #{url}" else raise "open_url_command cannot determine host OS" end return cmd end |