Class: IEgrip::IE

Inherits:
GripWrapper show all
Defined in:
lib/iegrip.rb

Overview

IE Application

Constant Summary collapse

COMPLETE_STATE =
4

Instance Method Summary collapse

Methods inherited from GripWrapper

#inspect, #ole_methodNames, #raw

Constructor Details

#initializeIE

Returns a new instance of IE.



17
18
19
20
21
22
23
24
25
26
# File 'lib/iegrip.rb', line 17

def initialize()
  @raw_object = WIN32OLE.new("InternetExplorer.Application")
  @raw_object.visible = true
  fs = FileSystemObject.instance
  ver = fs.GetFileVersion(@raw_object.FullName)
  @majorVersion = ver.split(/\./)[0].to_i
  @urlDownloadToFile = Win32API.new('urlmon', 'URLDownloadToFileA', %w(l p p l l), 'l')
  @event = WIN32OLE_EVENT.new(@raw_object,"DWebBrowserEvents2")
  setup_event()
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class IEgrip::GripWrapper

Instance Method Details

#before_waitObject



42
43
44
45
# File 'lib/iegrip.rb', line 42

def before_wait()
  @location_url = nil
  @complete_flag = nil
end

#documentObject



32
33
34
# File 'lib/iegrip.rb', line 32

def document()
  doc = Document.new(@raw_object.Document, self)
end

#export(href, filename) ⇒ Object



57
58
59
# File 'lib/iegrip.rb', line 57

def export(href, filename)
  @urlDownloadToFile.call(0, href, filename, 0, 0)
end


36
37
38
39
40
# File 'lib/iegrip.rb', line 36

def navigate(url)
  before_wait()
  @raw_object.navigate(url)
  wait_stable()
end

#versionObject



28
29
30
# File 'lib/iegrip.rb', line 28

def version
  @majorVersion
end

#wait_stable(timeout = 30) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/iegrip.rb', line 48

def wait_stable(timeout=30)
  start_time = Time.now
  loop do
    break if @complete_flag
    break if (Time.now - start_time) > timeout
    WIN32OLE_EVENT.message_loop
  end
end