Module | Composite |
In: |
lib/webgen/composite.rb
|
Adds the child
# File lib/webgen/composite.rb, line 71 71: def add_child( child ) 72: @children = [] unless defined?( @children ) 73: @children.push( child ) unless child.nil? || @children.include?( child ) 74: end
Adds all objects in the array
# File lib/webgen/composite.rb, line 54 54: def add_children( array ) 55: if array.kind_of?( Array ) 56: @children = [] unless defined?( @children ) 57: @children.concat( array.compact ) 58: else 59: raise ArgumentError, "Parameter must be array" 60: end 61: end
Depending on the type of argument one of these actions is taken
# File lib/webgen/composite.rb, line 81 81: def del_child( child ) 82: if child.kind_of?( Numeric ) 83: @children.delete_at( child ) if defined?( @children ) 84: else 85: @children.delete( child ) if defined?( @children ) 86: end 87: end
Iterates over all childrenldren
# File lib/webgen/composite.rb, line 91 91: def each # :yields: child 92: @children.each {|child| yield child } if defined?( @children ) 93: end