Class: PPTX::Shapes::FilledRectangle

Inherits:
Shape
  • Object
show all
Defined in:
lib/pptx/shapes/filled_rectangle.rb

Instance Method Summary collapse

Methods inherited from Shape

#base_node, #build_solid_fill, #set_shape_properties

Constructor Details

#initialize(transform, color) ⇒ FilledRectangle

Returns a new instance of FilledRectangle.



4
5
6
7
# File 'lib/pptx/shapes/filled_rectangle.rb', line 4

def initialize(transform, color)
  super(transform)
  @color = color
end

Instance Method Details

#base_xmlObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pptx/shapes/filled_rectangle.rb', line 9

def base_xml
  # TODO replace cNvPr descr, id and name
  """
    <p:sp xmlns:a='http://schemas.openxmlformats.org/drawingml/2006/main'
          xmlns:p='http://schemas.openxmlformats.org/presentationml/2006/main'>
        <p:nvSpPr>
            <p:cNvPr id='2' name='Rectangle'/>
            <p:cNvSpPr/>
            <p:nvPr/>
        </p:nvSpPr>
        <p:spPr>
        </p:spPr>
    </p:sp>
  """
end

#build_nodeObject



25
26
27
28
29
# File 'lib/pptx/shapes/filled_rectangle.rb', line 25

def build_node
  base_node.tap do |node|
    node.xpath('.//p:spPr', p: Presentation::NS).first.add_child build_solid_fill @color
  end
end