Class: Webkit

Inherits:
Browser show all
Defined in:
lib/hanoi/browsers/webkit.rb

Direct Known Subclasses

Safari

Instance Method Summary collapse

Methods inherited from Browser

#escaped_name, #host, #installed?, #linux?, #macos?, #name, #path, #runnable?, #to_s, #windows?

Constructor Details

#initialize(path = File.join(ENV['WEBKIT_HOME'] || ENV['ProgramFiles'] || 'C:\Program Files', 'Webkit', 'webkit.exe')) ⇒ Webkit

Returns a new instance of Webkit.



2
3
4
# File 'lib/hanoi/browsers/webkit.rb', line 2

def initialize(path = File.join(ENV['WEBKIT_HOME'] || ENV['ProgramFiles'] || 'C:\Program Files', 'Webkit', 'webkit.exe'))
  @path = path
end

Instance Method Details

#setupObject



10
11
12
# File 'lib/hanoi/browsers/webkit.rb', line 10

def setup
  applescript(%(tell application "#{name}" to make new document)) if macos?
end

#supported?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/hanoi/browsers/webkit.rb', line 6

def supported?
  macos? || windows?
end

#teardownObject



22
23
24
# File 'lib/hanoi/browsers/webkit.rb', line 22

def teardown
  #applescript('tell application "Safari" to close front document')
end

#visit(url) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/hanoi/browsers/webkit.rb', line 14

def visit(url)
  if macos?
    applescript(%(tell application "#{name}" to set URL of front document to "#{url}"))
  elsif windows?
    system("#{path} #{url}")
  end
end