Class: PPTXMarkdown::Slide

Inherits:
Struct
  • Object
show all
Defined in:
lib/pptx_markdown/slide.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#shapesObject

Returns the value of attribute shapes

Returns:

  • (Object)

    the current value of shapes



2
3
4
# File 'lib/pptx_markdown/slide.rb', line 2

def shapes
  @shapes
end

Instance Method Details

#to_markdownObject



3
4
5
# File 'lib/pptx_markdown/slide.rb', line 3

def to_markdown
  shapes.map(&:to_markdown).join
end

#to_xml(index) ⇒ String

Returns XML ppt/slides/slide0.xml with nested shapes.

Returns:

  • (String)

    XML ppt/slides/slide0.xml with nested shapes



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pptx_markdown/slide.rb', line 8

def to_xml(index)
  node_collection = PPTXMarkdown::ShapeMapper.new

  Nokogiri::XML::Builder.new do |xml|
    xml['p'].sld(XML_NAMESPACES) do
      xml.cSld do
        xml.spTree do
          xml.nvGrpSpPr do
            xml.cNvPr(id: 255 + index + 1, name: nil)
            xml.cNvGrpSpPr
            xml.nvPr
          end
          xml.grpSpPr do
            xml['a'].xfrm do
              xml.off(x: 0, y: 0)
              xml.ext(cx: 0, cy: 0)
              xml.chOff(x: 0, y: 0)
              xml.chExt(cx: 0, cy: 0)
            end
          end
          shapes.each do |shape|
            xml << shape.to_xml(node_collection.next)
          end
        end
      end
      xml.clrMapOvr do
        xml['a'].masterClrMapping
      end
    end
  end.to_xml
end