Class: Rapinoe::Slide

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

Overview

‘Slide` is a really vague approximation. Keynote stores its data in a zip-compressed file that has a bunch of .iwa files in it, which is where it stores its data. Each of those .iwa files is a file that’s been compressed with a non-standard version of Google’s Snappy compression format, and in turn the resulting data is stored in Google’s Protobuf interchange format.

I think we could probably get pretty deep into this, but I couldn’t get the Ruby Snappy bindings to decompress the .iwa data (presumably due to the lacking Stream Identifier chunk). Might be something we look into later and see how many details we can glean from the full dataset.

For more information, see @obriensp’s excellent docs:

https://github.com/obriensp/iWorkFileFormat/blob/master/Docs/index.md

For now, we’re going to instead look at the generated jpeg previews inside the ‘Data/` subdirectory. It’s a nasty approximation, but it should map fairly well to the actual number of slides in the file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Slide

Returns a new instance of Slide.



23
24
25
# File 'lib/rapinoe/slide.rb', line 23

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject

The binary data representing the jpeg representation of this slide.



21
22
23
# File 'lib/rapinoe/slide.rb', line 21

def data
  @data
end

Instance Method Details

#inspectObject



42
43
44
# File 'lib/rapinoe/slide.rb', line 42

def inspect
  "<Rapinoe::Slide>"
end

#preview_dataObject

The contents of the preview jpeg, loaded into memory.

Returns a string of the jpeg’s binary data.



30
31
32
# File 'lib/rapinoe/slide.rb', line 30

def preview_data
  @data
end

#write_preview_to_file(path) ⇒ Object

Writes the preview for this slide to disk.



35
36
37
38
39
40
# File 'lib/rapinoe/slide.rb', line 35

def write_preview_to_file(path)
  FileUtils.mkdir_p(File.dirname(path))
  File.open(path, 'wb') do |out|
    out.write(preview_data)
  end
end