Class: Ballmer::Document

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ballmer/document.rb,
lib/ballmer/document/part.rb,
lib/ballmer/document/rels.rb,
lib/ballmer/document/archive.rb,
lib/ballmer/document/xml_part.rb,
lib/ballmer/document/content_types.rb

Overview

Deals with file concerns between higher-level classes like Slides, Notes and file-system level work.

Direct Known Subclasses

Presentation

Defined Under Namespace

Classes: Archive, ContentTypes, Part, Rels, XMLPart

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(archive) ⇒ Document

Returns a new instance of Document.



22
23
24
# File 'lib/ballmer/document.rb', line 22

def initialize(archive)
  @archive = archive
end

Instance Attribute Details

#archiveObject (readonly)

Make the archive available in case the developer needs to perform even lower level IO functions.



20
21
22
# File 'lib/ballmer/document.rb', line 20

def archive
  @archive
end

Class Method Details

.open(path) ⇒ Object

Open an XML office file from the given path.



27
28
29
# File 'lib/ballmer/document.rb', line 27

def self.open(path)
  new Archive.open(path)
end

.read(data) ⇒ Object

Read zip data from a bufffer. Very useful when you want to load a template into a server environment, modify, and serve up without writing to disk.



33
34
35
# File 'lib/ballmer/document.rb', line 33

def self.read(data)
  new Archive.read(data)
end

Instance Method Details

#content_typesObject

Content types XML file.



48
49
50
# File 'lib/ballmer/document.rb', line 48

def content_types
  ContentTypes.new(self)
end

#edit_xml(path, &block) ⇒ Object

Modify XML within a block and write it back to the zip when done.



43
44
45
# File 'lib/ballmer/document.rb', line 43

def edit_xml(path, &block)
  write path, xml(path).tap(&block).to_s
end

#xml(path) ⇒ Object

Open an XML document at the given path.



38
39
40
# File 'lib/ballmer/document.rb', line 38

def xml(path)
  Nokogiri::XML read path
end