Class: PPTX::Shapes::Picture

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

Instance Method Summary collapse

Methods inherited from Shape

#base_node, #build_solid_fill, #set_shape_properties

Constructor Details

#initialize(transform, relationship_id) ⇒ Picture

Returns a new instance of Picture.



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

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

Instance Method Details

#base_xmlObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pptx/shapes/picture.rb', line 9

def base_xml
  # TODO replace cNvPr descr, id and name
  """
    <p:pic xmlns:a='http://schemas.openxmlformats.org/drawingml/2006/main'
           xmlns:p='http://schemas.openxmlformats.org/presentationml/2006/main'>
      <p:nvPicPr>
          <p:cNvPr descr='test_photo.jpg' id='2' name='Picture 1'/>
          <p:cNvPicPr>
              <a:picLocks noChangeAspect='1'/>
          </p:cNvPicPr>
          <p:nvPr/>
      </p:nvPicPr>
      <p:blipFill>
          <a:blip r:embed='REPLACEME'/>
          <a:stretch>
              <a:fillRect/>
          </a:stretch>
      </p:blipFill>
      <p:spPr>
      </p:spPr>
  </p:pic>
  """
end

#build_nodeObject



33
34
35
36
37
# File 'lib/pptx/shapes/picture.rb', line 33

def build_node
  base_node.tap do |node|
    node.xpath('.//a:blip', a: DRAWING_NS).first['r:embed'] = @relationship_id
  end
end