Class: EPUB::Publication::Package

Inherits:
Object
  • Object
show all
Includes:
Inspector
Defined in:
lib/epub/publication/package.rb,
lib/epub/publication/package/guide.rb,
lib/epub/publication/package/spine.rb,
lib/epub/publication/package/bindings.rb,
lib/epub/publication/package/manifest.rb,
lib/epub/publication/package/metadata.rb

Defined Under Namespace

Classes: Bindings, Guide, Manifest, Spine

Constant Summary collapse

CONTENT_MODELS =
[:metadata, :manifest, :spine, :guide, :bindings]
RESERVED_VOCABULARY_PREFIXES =
{
  ''        => 'http://idpf.org/epub/vocab/package/#',
  'dcterms' => 'http://purl.org/dc/terms/',
  'marc'    => 'http://id.loc.gov/vocabulary/',
  'media'   => 'http://www.idpf.org/epub/vocab/overlays/#',
  'onix'    => 'http://www.editeur.org/ONIX/book/codelists/current.html#',
  'xsd'     => 'http://www.w3.org/2001/XMLSchema#'
}
Metadata =
EPUB::Metadata

Constants included from Inspector

Inspector::INSTANCE_VARIABLES_OPTION, Inspector::SIMPLE_TEMPLATE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#inspect_instance_variables, #inspect_object_id, #inspect_simply

Constructor Details

#initializePackage

Returns a new instance of Package.



38
39
40
# File 'lib/epub/publication/package.rb', line 38

def initialize
  @prefix = {}
end

Instance Attribute Details

#bookObject

Returns the value of attribute book.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def book
  @book
end

#dirObject

Returns the value of attribute dir.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def dir
  @dir
end

#idObject

Returns the value of attribute id.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def id
  @id
end

#prefixObject

Returns the value of attribute prefix.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def prefix
  @prefix
end

#versionObject

Returns the value of attribute version.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def version
  @version
end

#xml_langObject Also known as: lang

Returns the value of attribute xml_lang.



28
29
30
# File 'lib/epub/publication/package.rb', line 28

def xml_lang
  @xml_lang
end

Class Method Details

.define_content_model(model_name) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/epub/publication/package.rb', line 18

def define_content_model(model_name)
  define_method "#{model_name}=" do |model|
    current_model = __send__(model_name)
    current_model.package = nil if current_model
    model.package = self
    instance_variable_set "@#{model_name}", model
  end
end

Instance Method Details

#full_pathAddressable::URI

Full path in EPUB archive

Returns:

  • (Addressable::URI)


55
56
57
# File 'lib/epub/publication/package.rb', line 55

def full_path
  rootfile.full_path if rootfile
end

#inspectObject



59
60
61
62
63
64
65
66
# File 'lib/epub/publication/package.rb', line 59

def inspect
  "#<%{class}:%{object_id} %{attributes} %{models}>" % {
    :class      => self.class,
    :object_id  => inspect_object_id,
    :attributes => inspect_instance_variables(exclude: CONTENT_MODELS.map {|model| :"@#{model}"}),
    :models     => inspect_models
  }
end

#inspect_modelsObject



68
69
70
71
72
73
74
# File 'lib/epub/publication/package.rb', line 68

def inspect_models
  CONTENT_MODELS.map {|name|
    model = __send__(name)
    representation = model.nil? ? model.inspect : model.inspect_simply
    "@#{name}=#{representation}"
  }.join(' ')
end

#rootfileOCF::Container::Rootfile

Corresponding Rootfile



49
50
51
# File 'lib/epub/publication/package.rb', line 49

def rootfile
  @book.ocf.container.rootfiles.find {|rf| rf.package == self}
end

#unique_identifierEPUB::Metadata::Identifier

Returns Unique Identifier.

Returns:



43
44
45
# File 'lib/epub/publication/package.rb', line 43

def unique_identifier
  @metadata.unique_identifier
end