Class: Plaintext::PptxHandler

Inherits:
OfficeDocumentHandler show all
Defined in:
lib/plaintext/file_handler/zipped_xml_handler/office_document_handler/pptx_handler.rb

Constant Summary collapse

CONTENT_TYPES =
[
    'application/vnd.openxmlformats-officedocument.presentationml.presentation',
    'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
    'application/vnd.ms-powerpoint.template.macroEnabled.12'
]

Instance Method Summary collapse

Methods inherited from FileHandler

#accept?

Constructor Details

#initializePptxHandler

Returns a new instance of PptxHandler.



11
12
13
14
15
# File 'lib/plaintext/file_handler/zipped_xml_handler/office_document_handler/pptx_handler.rb', line 11

def initialize
  super
  @content_types = CONTENT_TYPES
  @namespace_uri = 'http://schemas.openxmlformats.org/drawingml/2006/main'
end

Instance Method Details

#text(file) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/plaintext/file_handler/zipped_xml_handler/office_document_handler/pptx_handler.rb', line 17

def text(file)
  slides = []
  Zip::File.open(file) do |zip_file|
    zip_file.each do |entry|
      if entry.name =~ /slide(\d+)\.xml/
        slides << [$1, xml_to_text(entry.get_input_stream)]
      end
    end
  end
  slides.sort!{|a, b| a.first <=> b.first}
  slides.map(&:last).join ' '
end