Class: Ruber::World::Environment::ViewList

Inherits:
Object
  • Object
show all
Defined in:
lib/ruber/world/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeViewList

Returns a new instance of ViewList.



34
35
36
37
38
39
# File 'lib/ruber/world/environment.rb', line 34

def initialize
  @by_activation = []
  @by_tab = {}
  @by_document = {}
  @tabs = {}
end

Instance Attribute Details

#by_activationObject (readonly)

Returns the value of attribute by_activation.



32
33
34
# File 'lib/ruber/world/environment.rb', line 32

def by_activation
  @by_activation
end

#by_documentObject (readonly)

Returns the value of attribute by_document.



32
33
34
# File 'lib/ruber/world/environment.rb', line 32

def by_document
  @by_document
end

#by_tabObject (readonly)

Returns the value of attribute by_tab.



32
33
34
# File 'lib/ruber/world/environment.rb', line 32

def by_tab
  @by_tab
end

#tabsObject (readonly)

Returns the value of attribute tabs.



32
33
34
# File 'lib/ruber/world/environment.rb', line 32

def tabs
  @tabs
end

Instance Method Details

#add_view(view, tab) ⇒ Object



41
42
43
44
45
46
# File 'lib/ruber/world/environment.rb', line 41

def add_view view, tab
  @by_activation << view
  (@by_tab[tab] ||= []) << view
  (@by_document[view.document] ||= []) << view
  @tabs[view] = tab
end

#move_to_front(view) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/ruber/world/environment.rb', line 58

def move_to_front view
  @by_activation.unshift @by_activation.delete(view)
  tab = @tabs[view]
  @by_tab[tab].unshift @by_tab[tab].delete(view)
  doc = view.document
  @by_document[doc].unshift @by_document[doc].delete(view)
end

#remove_view(view) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/ruber/world/environment.rb', line 48

def remove_view view
  tab = @tabs[view]
  @by_activation.delete view
  @by_tab[tab].delete view
  @by_tab.delete tab if @by_tab[tab].empty?
  @by_document[view.document].delete view
  @by_document.delete view.document if @by_document[view.document].empty?
  @tabs.delete view
end