Class: Webr::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/webr/browser.rb

Direct Known Subclasses

Jasmine::Browser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBrowser

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

#envObject (readonly)

Returns the value of attribute env.



3
4
5
# File 'lib/webr/browser.rb', line 3

def env
  @env
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



3
4
5
# File 'lib/webr/browser.rb', line 3

def runtime
  @runtime
end

#scriptsObject (readonly)

Returns the value of attribute scripts.



3
4
5
# File 'lib/webr/browser.rb', line 3

def scripts
  @scripts
end

Instance Method Details

#htmlObject



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.expand_path(file_or_url)
  @portal.root = File.dirname(path)
  @portal.html = File.new(path).read
end

#rootObject



25
26
27
# File 'lib/webr/browser.rb', line 25

def root
  @portal.root
end

#root=(root) ⇒ Object



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

def root=(root)
  @portal.root = root
end

#startObject



39
40
41
# File 'lib/webr/browser.rb', line 39

def start
  @runtime.start
end