Class: Steam::Browser::HtmlUnit::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/browser/html_unit/page.rb

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Page

Returns a new instance of Page.



10
11
12
# File 'lib/steam/browser/html_unit/page.rb', line 10

def initialize(page)
  @page = page
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



45
46
47
# File 'lib/steam/browser/html_unit/page.rb', line 45

def method_missing(method, *args)
  return @page.send(method, *args)
end

Instance Method Details

#bodyObject



29
30
31
# File 'lib/steam/browser/html_unit/page.rb', line 29

def body
  @page.asXml
end

#execute(javascript) ⇒ Object



33
34
35
# File 'lib/steam/browser/html_unit/page.rb', line 33

def execute(javascript)
  @page.executeJavaScript(javascript)
end

#headersObject



22
23
24
25
26
27
# File 'lib/steam/browser/html_unit/page.rb', line 22

def headers
  @page.getWebResponse.getResponseHeaders.toArray.inject({}) do |headers, pair|
    headers[pair.name] = pair.value
    headers
  end
end

#sourceCodeObject



37
38
39
# File 'lib/steam/browser/html_unit/page.rb', line 37

def sourceCode
  @page.asXml
end

#statusObject



18
19
20
# File 'lib/steam/browser/html_unit/page.rb', line 18

def status
  @page.getWebResponse.getStatusCode
end

#to_aObject



41
42
43
# File 'lib/steam/browser/html_unit/page.rb', line 41

def to_a
  [body, status, headers]
end

#urlObject



14
15
16
# File 'lib/steam/browser/html_unit/page.rb', line 14

def url
  @page.getWebResponse.getRequestSettings.getUrl.toString
end