Module: WindowBlessing::Window::ParentsAndChildren

Included in:
WindowBlessing::Window
Defined in:
lib/window_blessing/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



155
156
157
# File 'lib/window_blessing/window.rb', line 155

def children
  @children
end

#parentObject

Returns the value of attribute parent.



154
155
156
# File 'lib/window_blessing/window.rb', line 154

def parent
  @parent
end

Instance Method Details

#add_child(child) ⇒ Object



168
169
170
171
172
173
# File 'lib/window_blessing/window.rb', line 168

def add_child(child)
  children << child
  child.parent= self
  child.request_redraw
  child
end

#each_child(&block) ⇒ Object



181
182
183
# File 'lib/window_blessing/window.rb', line 181

def each_child(&block)
  children.each &block
end

#each_child_with_index(&block) ⇒ Object



185
186
187
# File 'lib/window_blessing/window.rb', line 185

def each_child_with_index(&block)
  children.each_with_index &block
end

#parent_pathObject



193
194
195
# File 'lib/window_blessing/window.rb', line 193

def parent_path
  parent && parent.path
end

#pathObject



189
190
191
# File 'lib/window_blessing/window.rb', line 189

def path
  [parent && parent.path,"#{self.class}#{self.area}#{":"+name if name}"].flatten.compact.join(',')
end

#remove_child(child) ⇒ Object

returns nil if nothing was done, otherwise returns child



158
159
160
161
162
163
164
165
166
# File 'lib/window_blessing/window.rb', line 158

def remove_child(child)
  length_before = children.length
  @children = children.select {|c| c!=child}
  if @children.length!=length_before
    child.request_redraw
    child.parent= nil
    child
  end
end