Class: Harmony::Page
- Inherits:
-
Object
- Object
- Harmony::Page
- Defined in:
- lib/harmony/page.rb
Defined Under Namespace
Modules: Window
Class Method Summary collapse
-
.fetch(uri) ⇒ Page
Create page from remote document.
Instance Method Summary collapse
-
#document ⇒ Object
Convenience method, equivalent to the return value of ‘page.execute_js(’window.document’)‘.
-
#execute_js(code) ⇒ Object
(also: #x)
Evaluate Javascript code within this page’s context.
-
#initialize(document = nil) ⇒ Page
constructor
Create new page containing given document.
-
#load(*paths) ⇒ Page
Load one or more javascript files in page’s context.
-
#to_html ⇒ String
Page as html document.
-
#window ⇒ Object
DOM document’s ‘window` object.
Constructor Details
#initialize(document = nil) ⇒ Page
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
Instance Method Details
#document ⇒ Object
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 |
#execute_js(code) ⇒ Object 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 |
#load(*paths) ⇒ Page
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 |
#to_html ⇒ String
Page as html document
118 119 120 |
# File 'lib/harmony/page.rb', line 118 def to_html document.innerHTML end |