Class: PPTX::Presentation
- Inherits:
-
OPC::Part
- Object
- OPC::BasePart
- OPC::Part
- PPTX::Presentation
- Defined in:
- lib/pptx/presentation.rb
Constant Summary collapse
- NS =
'http://schemas.openxmlformats.org/presentationml/2006/main'
- MIN_SLIDE_ID =
256
Instance Method Summary collapse
- #add_slide(slide) ⇒ Object
-
#initialize(package, part_name) ⇒ Presentation
constructor
A new instance of Presentation.
- #next_slide_id ⇒ Object
- #slide_list_xml ⇒ Object
Methods inherited from OPC::Part
#relationship_part_name, #relationships, #relative_part_name
Methods inherited from OPC::BasePart
#base_xml, #content_type, #doc, #marshal, #part_name, #template
Constructor Details
#initialize(package, part_name) ⇒ Presentation
Returns a new instance of Presentation.
6 7 8 |
# File 'lib/pptx/presentation.rb', line 6 def initialize(package, part_name) super(package, part_name) end |
Instance Method Details
#add_slide(slide) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pptx/presentation.rb', line 10 def () # TODO remove me - remove existing slide from template # slide_list_xml.xpath('./p:sldId').each do |slide| # slide_list.children.delete(slide) # end ref_id = relationships.add(relative_part_name(.part_name), RELTYPE_SLIDE) # add slide to sldIdList in presentation = Nokogiri::XML::Node.new('p:sldId', doc) ['id'] = ['r:id'] = ref_id .add_child() end |
#next_slide_id ⇒ Object
24 25 26 27 |
# File 'lib/pptx/presentation.rb', line 24 def ids = .xpath('./p:sldId').map { |sid| sid['id'].to_i } return (ids.max || MIN_SLIDE_ID - 1) + 1 end |
#slide_list_xml ⇒ Object
29 30 31 |
# File 'lib/pptx/presentation.rb', line 29 def @slide_list_xml ||= doc.xpath('/p:presentation/p:sldIdLst', p: NS).first end |