Class: Ruber::World::Environment::ViewList
- Inherits:
-
Object
- Object
- Ruber::World::Environment::ViewList
- Defined in:
- lib/ruber/world/environment.rb
Instance Attribute Summary (collapse)
-
- (Object) by_activation
readonly
Returns the value of attribute by_activation.
-
- (Object) by_document
readonly
Returns the value of attribute by_document.
-
- (Object) by_tab
readonly
Returns the value of attribute by_tab.
-
- (Object) tabs
readonly
Returns the value of attribute tabs.
Instance Method Summary (collapse)
- - (Object) add_view(view, tab)
-
- (ViewList) initialize
constructor
A new instance of ViewList.
- - (Object) move_to_front(view)
- - (Object) remove_view(view)
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 |