Class: Harmony::Page
- Inherits:
-
Object
- Object
- Harmony::Page
- Defined in:
- lib/harmony/page.rb
Defined Under Namespace
Modules: Window
Class Method Summary (collapse)
-
+ (Page) fetch(uri)
Create page from remote document.
Instance Method Summary (collapse)
-
- (Object) document
Convenience method, equivalent to the return value of `page.execute_js('window.document')`.
-
- (Object) execute_js(code)
(also: #x)
Evaluate Javascript code within this page's context.
-
- (Page) initialize(document = nil)
constructor
Create new page containing given document.
-
- (Page) load(*paths)
Load one or more javascript files in page's context.
-
- (String) to_html
Page as html document.
-
- (Object) window
DOM document's `window` object.
Constructor Details
- (Page) initialize(document = nil)
Create new page containing given document.
64 65 66 |
# File 'lib/harmony/page.rb', line 64 def initialize(document=nil) @window = Window.from_document(document) if document end |
Class Method Details
+ (Page) fetch(uri)
Create page from remote document.
52 53 54 55 56 |
# File 'lib/harmony/page.rb', line 52 def self.fetch(uri) page = new page.instance_variable_set(:@window, Window.from_uri(uri)) page end |
Instance Method Details
- (Object) document
Convenience method, equivalent to the return value of `page.execute_js('window.document')`
110 111 112 |
# File 'lib/harmony/page.rb', line 110 def document window.document end |
- (Object) execute_js(code) Also known as: x
Evaluate Javascript code within this page's context.
89 90 91 |
# File 'lib/harmony/page.rb', line 89 def execute_js(code) window.evaluate(code) end |
- (Page) load(*paths)
Load one or more javascript files in page's context
74 75 76 77 78 79 |
# File 'lib/harmony/page.rb', line 74 def load(*paths) paths.flatten.each do |path| window.load(path.to_s) end self end |
- (String) to_html
Page as html document
118 119 120 |
# File 'lib/harmony/page.rb', line 118 def to_html document.innerHTML end |
- (Object) window
DOM document's `window` object. Equivalent to the return value of `page.execute_js('window')`
100 101 102 |
# File 'lib/harmony/page.rb', line 100 def window @window ||= Window.blank end |