Class: Browser
- Inherits:
-
Object
show all
- Defined in:
- lib/hanoi/browser.rb
Instance Method Summary
collapse
Instance Method Details
#escaped_name ⇒ Object
39
40
41
|
# File 'lib/hanoi/browser.rb', line 39
def escaped_name
name.gsub(' ', '\ ')
end
|
#host ⇒ Object
7
8
9
10
|
# File 'lib/hanoi/browser.rb', line 7
def host
require 'rbconfig'
Config::CONFIG['host']
end
|
#linux? ⇒ Boolean
20
21
22
|
# File 'lib/hanoi/browser.rb', line 20
def linux?
host.include?('linux')
end
|
#macos? ⇒ Boolean
12
13
14
|
# File 'lib/hanoi/browser.rb', line 12
def macos?
host.include?('darwin')
end
|
#name ⇒ Object
34
35
36
37
|
# File 'lib/hanoi/browser.rb', line 34
def name
n = self.class.name.split('::').last
linux? ? n.downcase : n
end
|
#open(url) ⇒ Object
4
|
# File 'lib/hanoi/browser.rb', line 4
def open(url) ; end
|
#path ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/hanoi/browser.rb', line 43
def path
if macos?
File.expand_path("/Applications/#{escaped_name}.app")
else
@path
end
end
|
#setup ⇒ Object
3
|
# File 'lib/hanoi/browser.rb', line 3
def setup ; end
|
#supported? ⇒ Boolean
2
|
# File 'lib/hanoi/browser.rb', line 2
def supported?; true; end
|
#teardown ⇒ Object
5
|
# File 'lib/hanoi/browser.rb', line 5
def teardown ; end
|
#to_s ⇒ Object
51
52
53
|
# File 'lib/hanoi/browser.rb', line 51
def to_s
name
end
|
#visit(url) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/hanoi/browser.rb', line 24
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
16
17
18
|
# File 'lib/hanoi/browser.rb', line 16
def windows?
host.include?('mswin')
end
|