module Cura::Attributes::HasWindows
Allows an object to have windows. TODO: Lots of code is the same as HasChildren
Attributes
windows[R]
Get the windows of this object.
Public Class Methods
new(*arguments)
click to toggle source
Calls superclass method
# File lib/cura/attributes/has_windows.rb, line 8 def initialize(*arguments) @windows = [] super end
Public Instance Methods
add_window(window)
click to toggle source
Add a window to this object.
@param [Window] window @return [Window]
# 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)
click to toggle source
Remove a window from this object's windows.
@param [Window] window @return [Window]
# 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)
click to toggle source
Remove a window from this object's windows at the given index.
@param [#to_i] index @return [Window]
# File lib/cura/attributes/has_windows.rb, line 33 def delete_window_at(index) @windows.delete_at(index.to_i) end
delete_windows()
click to toggle source
Remove all windows.
# File lib/cura/attributes/has_windows.rb, line 49 def delete_windows (0...@windows.count).to_a.each { |index| delete_window_at(index) } end