Class: Pincers::Chenso::BrowsingManager

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pincers/chenso/browsing_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(_client) ⇒ BrowsingManager

Returns a new instance of BrowsingManager.



9
10
11
12
13
14
15
# File 'lib/pincers/chenso/browsing_manager.rb', line 9

def initialize(_client)
  @client = _client
  @index = 0
  @windows = [
    [build_root_context]
  ]
end

Instance Method Details

#load_frame(_id, _request) ⇒ Object



37
38
39
40
41
# File 'lib/pincers/chenso/browsing_manager.rb', line 37

def load_frame(_id, _request)
  child_context = context.load_child _id
  child_context.push _request
  window << child_context
end

#load_window(_request) ⇒ Object



43
44
45
46
47
48
# File 'lib/pincers/chenso/browsing_manager.rb', line 43

def load_window(_request)
  context = build_root_context
  context.push _request
  windows << [context]
  @index = windows.length - 1
end

#switch_frame(_id) ⇒ Object



22
23
24
25
26
27
# File 'lib/pincers/chenso/browsing_manager.rb', line 22

def switch_frame(_id)
  new_context = context.get_child _id
  return false if new_context.nil?
  window << new_context
  return true
end

#switch_parent_frameObject



33
34
35
# File 'lib/pincers/chenso/browsing_manager.rb', line 33

def switch_parent_frame
  window.pop if window.length > 1
end

#switch_top_frameObject



29
30
31
# File 'lib/pincers/chenso/browsing_manager.rb', line 29

def switch_top_frame
  window.slice!(1..-1) if window.length > 1
end

#switch_window(_index) ⇒ Object



17
18
19
20
# File 'lib/pincers/chenso/browsing_manager.rb', line 17

def switch_window(_index)
  @index = _index
  switch_top_frame
end