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

- (ViewList) initialize

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

- (Object) by_activation (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

- (Object) by_document (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

- (Object) by_tab (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

- (Object) tabs (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

- (Object) add_view(view, tab)



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

- (Object) move_to_front(view)



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

- (Object) remove_view(view)



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