Class: Odf::Document::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/odf/document/abstract.rb

Direct Known Subclasses

Presentation, Spreadsheet, Text

Constant Summary collapse

COMPONENTS =
[:content, :manifest, :meta, :mime_type, :styles, :settings]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAbstract

Returns a new instance of Abstract.



11
12
13
14
15
16
17
18
19
# File 'lib/odf/document/abstract.rb', line 11

def initialize
  @content   = Odf::Component::Content.new(self)
  @image_set = Odf::Component::ImageSet.new(self)
  @manifest  = Odf::Component::Manifest.new(self)
  @meta      = Odf::Component::Meta.new(self)
  @mime_type = Odf::Component::MimeType.new(self)
  @settings  = Odf::Component::Settings.new(self)
  @styles    = Odf::Component::Styles.new(self)
end

Instance Attribute Details

#creatorObject

Returns the creator information.



44
45
46
# File 'lib/odf/document/abstract.rb', line 44

def creator
  @creator || Odf.creator
end

Instance Method Details

#add_image(uri) ⇒ Object



58
59
60
# File 'lib/odf/document/abstract.rb', line 58

def add_image(uri)
  image_set << uri
end

#componentsObject

Returns the components of the document.



39
40
41
# File 'lib/odf/document/abstract.rb', line 39

def components
  COMPONENTS
end

#extensionObject

Returns the file extension for open document format.



30
31
32
# File 'lib/odf/document/abstract.rb', line 30

def extension
  self.class::EXTENSION
end

#media_typeObject

Returns the mime type of document. All subclasses of this abstract class should define the MIME_TYPE constant.



24
25
26
# File 'lib/odf/document/abstract.rb', line 24

def media_type
  self.class::MIME_TYPE
end

#rootObject



62
63
64
# File 'lib/odf/document/abstract.rb', line 62

def root
  content.root
end

#serialize(file_name) ⇒ Object

Serialize the document to given path.



49
50
51
# File 'lib/odf/document/abstract.rb', line 49

def serialize(file_name)
  Odf::Utils::File.serialize(file_name, self) && true
end

#to_blobObject

Returns the output stream.



54
55
56
# File 'lib/odf/document/abstract.rb', line 54

def to_blob
  Odf::Utils::File.output_stream(self)
end

#wrapperObject



34
35
36
# File 'lib/odf/document/abstract.rb', line 34

def wrapper
  self.class::WRAPPER
end