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/metadata.rb,
lib/epub/publication/package/manifest.rb,
lib/epub/publication/package/bindings.rb

Defined Under Namespace

Classes: Bindings, Guide, Manifest, Metadata, 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#'
}

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

#inspectObject


46
47
48
49
50
51
52
53
# File 'lib/epub/publication/package.rb', line 46

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


55
56
57
58
59
60
61
# File 'lib/epub/publication/package.rb', line 55

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

#unique_identifierObject


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

def unique_identifier
  @metadata.unique_identifier
end