Class: Browser
- Inherits:
-
Object
- Object
- Browser
- Defined in:
- lib/zfben_hanoi/browser.rb
Instance Method Summary collapse
- #escaped_name ⇒ Object
- #host ⇒ Object
- #installed? ⇒ Boolean
- #linux? ⇒ Boolean
- #macos? ⇒ Boolean
- #name ⇒ Object
- #path ⇒ Object
- #runnable? ⇒ Boolean
- #setup ⇒ Object
- #supported? ⇒ Boolean
- #teardown ⇒ Object
- #to_s ⇒ Object
- #visit(url) ⇒ Object
- #windows? ⇒ Boolean
Instance Method Details
#escaped_name ⇒ Object
50 51 52 |
# File 'lib/zfben_hanoi/browser.rb', line 50 def escaped_name name.gsub(' ', '\ ') end |
#host ⇒ Object
6 7 8 9 |
# File 'lib/zfben_hanoi/browser.rb', line 6 def host require 'rbconfig' Config::CONFIG['host'] end |
#installed? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/zfben_hanoi/browser.rb', line 23 def installed? if linux? Kernel.system "which #{name}" else File.exist? path end end |
#linux? ⇒ Boolean
19 20 21 |
# File 'lib/zfben_hanoi/browser.rb', line 19 def linux? host.include?('linux') end |
#macos? ⇒ Boolean
11 12 13 |
# File 'lib/zfben_hanoi/browser.rb', line 11 def macos? host.include?('darwin') end |
#name ⇒ Object
45 46 47 48 |
# File 'lib/zfben_hanoi/browser.rb', line 45 def name n = self.class.name.split('::').last linux? ? n.downcase : n end |
#path ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/zfben_hanoi/browser.rb', line 54 def path if macos? File.("/Applications/#{escaped_name}.app") else @path end end |
#runnable? ⇒ Boolean
31 32 33 |
# File 'lib/zfben_hanoi/browser.rb', line 31 def runnable? supported? && installed? end |
#setup ⇒ Object
3 |
# File 'lib/zfben_hanoi/browser.rb', line 3 def setup; end |
#supported? ⇒ Boolean
2 |
# File 'lib/zfben_hanoi/browser.rb', line 2 def supported?; true; end |
#teardown ⇒ Object
4 |
# File 'lib/zfben_hanoi/browser.rb', line 4 def teardown; end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/zfben_hanoi/browser.rb', line 62 def to_s name end |
#visit(url) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/zfben_hanoi/browser.rb', line 35 def visit(url) if macos? system("open -g -a #{path} '#{url}'") elsif windows? system("#{path} #{url}") elsif linux? system("#{name} #{url}") end end |
#windows? ⇒ Boolean
15 16 17 |
# File 'lib/zfben_hanoi/browser.rb', line 15 def windows? /mswin|mingw/.match host end |