Class: SVGen::Element::Group

Inherits:
Object
  • Object
show all
Includes:
Nestable
Defined in:
lib/svgen/element/group.rb

Instance Method Summary collapse

Methods included from Nestable

#circle, #group, #line, #path, #rect, #text

Constructor Details

#initialize(attrs = {}, &block) ⇒ Group

Returns a new instance of Group.



6
7
8
9
10
# File 'lib/svgen/element/group.rb', line 6

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

Instance Method Details

#generate(svg) ⇒ Object



12
13
14
15
16
# File 'lib/svgen/element/group.rb', line 12

def generate(svg)
  svg.g(@attrs) do |g|
    @children.each { |child| child.generate(g) }
  end
end