Sha256: f68eee3b569374333395ff1ff25d58df94c0fff0e2da503102900021ddbfdb30

Contents?: true

Size: 430 Bytes

Versions: 2

Compression:

Stored size: 430 Bytes

Contents

module Docxtor2
  class ElementList
    def initialize
      @elements = []
    end

    def self.map(mappings)
      mappings.each do |name, klass|
        define_method(name) do |*args, &block|
          self << klass.new(*args, &block)
        end
      end
    end

    protected

    def write_elements(xml)
      @elements.each { |el| el.render(xml) }
    end

    def <<(el)
      @elements << el
      el
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docxtor2-0.0.9 lib/docxtor2/element_list.rb
docxtor2-0.1.0 lib/docxtor2/element_list.rb