Sha256: 1839c2692f25030c2df3665cc970a2658b1099ea01199d5620803e94a268e1ae

Contents?: true

Size: 368 Bytes

Versions: 5

Compression:

Stored size: 368 Bytes

Contents

require 'jschematic/element'

module Jschematic
  module Composite
    include Enumerable
    include Jschematic::Element

    def children
      @children ||= []
    end

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

    def each(&block)
      block.call(self)
      children.each{ |child| child.each(&block) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jschematic-0.1.0 lib/jschematic/composite.rb
jschematic-0.0.9 lib/jschematic/composite.rb
jschematic-0.0.6 lib/jschematic/composite.rb
jschematic-0.0.5 lib/jschematic/composite.rb
jschematic-0.0.2 lib/jschematic/composite.rb