Sha256: 473e8a251dcfd927da5f8e91a5641b461c53fc7c151dd8d9ca27b38d7e8ee08e

Contents?: true

Size: 427 Bytes

Versions: 2

Compression:

Stored size: 427 Bytes

Contents

require "builder"

module SVGen
  class SVG
    include Nestable

    def initialize(attrs = {}, &block)
      @children = []
      @attrs = attrs
      block.call(self) if block_given?
    end

    def generate
      builder = Builder::XmlMarkup.new(indent: 2)
      builder.svg(@attrs.merge({ xmlns: "http://www.w3.org/2000/svg" })) do |svg|
        @children.each { |child| child.generate(svg) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
svgen-0.1.0 lib/svgen/svg.rb
svgen-0.0.3 lib/svgen/svg.rb