Class: Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/hanoi/browser.rb

Direct Known Subclasses

Chrome, Firefox, InternetExplorer, Konqueror, Opera, Webkit

Instance Method Summary collapse

Instance Method Details

#escaped_nameObject



39
40
41
# File 'lib/hanoi/browser.rb', line 39

def escaped_name
  name.gsub(' ', '\ ')
end

#hostObject



7
8
9
10
# File 'lib/hanoi/browser.rb', line 7

def host
  require 'rbconfig'
  Config::CONFIG['host']
end

#linux?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/hanoi/browser.rb', line 20

def linux?
  host.include?('linux')
end

#macos?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/hanoi/browser.rb', line 12

def macos?
  host.include?('darwin')
end

#nameObject



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

#pathObject



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

#setupObject



3
# File 'lib/hanoi/browser.rb', line 3

def setup ; end

#supported?Boolean

Returns:

  • (Boolean)


2
# File 'lib/hanoi/browser.rb', line 2

def supported?; true; end

#teardownObject



5
# File 'lib/hanoi/browser.rb', line 5

def teardown ; end

#to_sObject



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

Returns:

  • (Boolean)


16
17
18
# File 'lib/hanoi/browser.rb', line 16

def windows?
  host.include?('mswin')
end