Module: Cura::Attributes::HasWindows
- Included in:
- Cura::Application
- Defined in:
- lib/cura/attributes/has_windows.rb
Overview
Allows an object to have windows. TODO: Lots of code is the same as HasChildren
Instance Attribute Summary collapse
-
#windows ⇒ Object
readonly
Get the windows of this object.
Instance Method Summary collapse
-
#add_window(window) ⇒ Window
Add a window to this object.
-
#delete_window(window) ⇒ Window
Remove a window from this object’s windows.
-
#delete_window_at(index) ⇒ Window
Remove a window from this object’s windows at the given index.
-
#delete_windows ⇒ Object
Remove all windows.
- #initialize(*arguments) ⇒ Object
Instance Attribute Details
#windows ⇒ Object (readonly)
Get the windows of this object.
15 16 17 |
# File 'lib/cura/attributes/has_windows.rb', line 15 def windows @windows end |
Instance Method Details
#add_window(window) ⇒ Window
Add a window to this object.
21 22 23 24 25 26 27 |
# File 'lib/cura/attributes/has_windows.rb', line 21 def add_window(window) raise TypeError, "window must be a Cura::Window" unless window.is_a?(Window) @windows << window window end |
#delete_window(window) ⇒ Window
Remove a window from this object’s windows.
41 42 43 44 45 46 |
# File 'lib/cura/attributes/has_windows.rb', line 41 def delete_window(window) raise TypeError, "window must be a Cura::Window" unless window.is_a?(Window) index = @windows.index(window) delete_window_at(index) end |
#delete_window_at(index) ⇒ Window
Remove a window from this object’s windows at the given index.
33 34 35 |
# File 'lib/cura/attributes/has_windows.rb', line 33 def delete_window_at(index) @windows.delete_at(index.to_i) end |
#delete_windows ⇒ Object
Remove all windows.
49 50 51 |
# File 'lib/cura/attributes/has_windows.rb', line 49 def delete_windows (0...@windows.count).to_a.each { |index| delete_window_at(index) } end |
#initialize(*arguments) ⇒ Object
8 9 10 11 12 |
# File 'lib/cura/attributes/has_windows.rb', line 8 def initialize(*arguments) @windows = [] super end |