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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector::PublicationModel

included, #inspect, #template

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) ⇒ Manifest

Returns self

Parameters:

Returns:



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

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

#[](item_id) ⇒ Item?

Parameters:

  • item_id (String)

Returns:



74
75
76
# File 'lib/epub/publication/package/manifest.rb', line 74

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

#cover_imageItem?

Returns item which includes “cover-image” as one of properties. It represents this item is cover image.

Returns:

  • (Item, nil)

    item which includes “cover-image” as one of properties. It represents this item is cover image.



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

def cover_image
  items.find(&:cover_image?)
end

#each_item {|item| ... } ⇒ Object #each_itemEnumerator

Overloads:

  • #each_item {|item| ... } ⇒ Object

    Yields:

    • (item)

    Yield Parameters:

  • #each_itemEnumerator

    Returns:

    • (Enumerator)


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

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

#each_navObject



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

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



68
69
70
# File 'lib/epub/publication/package/manifest.rb', line 68

def items
  @items.values
end

Returns the first item of #navs

Returns:

  • (Item, nil)

    the first item of #navs



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

def nav
  navs.first
end

Returns item which includes “nav” as one of properties. It represents this item is a navigation of book.

Returns:

  • (Array<Item>)

    item which includes “nav” as one of properties. It represents this item is a navigation of book.



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

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