Class: EPUB::Publication::Package::Manifest

Inherits:
Object
  • Object
show all
Includes:
Inspector::PublicationModel
Defined in:
lib/epub/publication/package/manifest.rb

Defined Under Namespace

Classes: Item

Constant Summary

Constants included from Inspector::PublicationModel

Inspector::PublicationModel::TEMPLATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector::PublicationModel

included, #inspect

Constructor Details

#initializeManifest

Returns a new instance of Manifest.



16
17
18
# File 'lib/epub/publication/package/manifest.rb', line 16

def initialize
  @items = {}
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



13
14
15
# File 'lib/epub/publication/package/manifest.rb', line 13

def id
  @id
end

#packageObject

Returns the value of attribute package.



13
14
15
# File 'lib/epub/publication/package/manifest.rb', line 13

def package
  @package
end

Instance Method Details

#<<(item) ⇒ Object

Returns self.

Returns:

  • self



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

def <<(item)
  item.manifest = self
  @items[item.id] = item
  self
end

#[](item_id) ⇒ Object



63
64
65
# File 'lib/epub/publication/package/manifest.rb', line 63

def [](item_id)
  @items[item_id]
end

#cover_imageObject



45
46
47
# File 'lib/epub/publication/package/manifest.rb', line 45

def cover_image
  items.select(&:cover_image?).first
end

#each_itemObject



49
50
51
52
53
54
55
56
57
# File 'lib/epub/publication/package/manifest.rb', line 49

def each_item
  if block_given?
    @items.each_value do |item|
      yield item
    end
  else
    @items.each_value
  end
end

#each_navObject



27
28
29
30
31
32
33
34
35
# File 'lib/epub/publication/package/manifest.rb', line 27

def each_nav
  if block_given?
    each_item do |item|
      yield item if item.nav?
    end
  else
    each_item.lazy.select(&:nav?)
  end
end

#itemsObject



59
60
61
# File 'lib/epub/publication/package/manifest.rb', line 59

def items
  @items.values
end


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

def nav
  navs.first
end


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

def navs
  items.select(&:nav?)
end