Class: Webr::Browser
- Inherits:
-
Object
- Object
- Webr::Browser
- Defined in:
- lib/webr/browser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#scripts ⇒ Object
readonly
Returns the value of attribute scripts.
Instance Method Summary collapse
- #html ⇒ Object
- #html=(html) ⇒ Object
-
#initialize ⇒ Browser
constructor
A new instance of Browser.
- #open(file_or_url) ⇒ Object
- #root ⇒ Object
- #root=(root) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Browser
Returns a new instance of Browser.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/webr/browser.rb', line 5 def initialize @runtime = Webr::Runtime.new("#{SCRIPT_PATH}/webr.js") @portal = @runtime.portal @portal.require_paths << "#{Webr::HOME_PATH}/ext" @portal.require_paths << "#{Webr::HOME_PATH}/ext/request" @portal.require_paths << "#{Webr::HOME_PATH}/ext/jsdom/lib" @portal.html = "<html><head></head><body></body></html>" # not so nice @env = @portal.env @scripts = @portal.scripts end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
3 4 5 |
# File 'lib/webr/browser.rb', line 3 def env @env end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
3 4 5 |
# File 'lib/webr/browser.rb', line 3 def runtime @runtime end |
#scripts ⇒ Object (readonly)
Returns the value of attribute scripts.
3 4 5 |
# File 'lib/webr/browser.rb', line 3 def scripts @scripts end |
Instance Method Details
#html ⇒ Object
32 33 34 |
# File 'lib/webr/browser.rb', line 32 def html @portal.html end |
#html=(html) ⇒ Object
35 36 37 |
# File 'lib/webr/browser.rb', line 35 def html=(html) @portal.html = html end |
#open(file_or_url) ⇒ Object
19 20 21 22 23 |
# File 'lib/webr/browser.rb', line 19 def open(file_or_url) path = File.(file_or_url) @portal.root = File.dirname(path) @portal.html = File.new(path).read end |
#root=(root) ⇒ Object
28 29 30 |
# File 'lib/webr/browser.rb', line 28 def root=(root) @portal.root = root end |
#start ⇒ Object
39 40 41 |
# File 'lib/webr/browser.rb', line 39 def start @runtime.start end |