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.


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

def initialize
  @items = {}
end

Instance Attribute Details

#idObject

Returns the value of attribute id


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

def id
  @id
end

#packageObject

Returns the value of attribute package


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

def package
  @package
end

Instance Method Details

#<<(item) ⇒ Object

Returns self.

Returns:

  • self


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

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

#[](item_id) ⇒ Object


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

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

#cover_imageObject


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

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

#each_itemObject


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

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

#each_navObject


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

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


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

def items
  @items.values
end

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

def nav
  navs.first
end

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

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