Class: EPUB::Publication::Package::Manifest
- Inherits:
-
Object
- Object
- EPUB::Publication::Package::Manifest
- Includes:
- Inspector::PublicationModel
- Defined in:
- lib/epub/publication/package/manifest.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#package ⇒ Object
Returns the value of attribute package.
Instance Method Summary collapse
-
#<<(item) ⇒ Manifest
Self.
- #[](item_id) ⇒ Item?
-
#cover_image ⇒ Item?
Item which includes “cover-image” as one of
properties
. - #each_item ⇒ Object
- #each_nav ⇒ Object
-
#initialize ⇒ Manifest
constructor
A new instance of Manifest.
- #items ⇒ Object
-
#nav ⇒ Item?
The first item of #navs.
-
#navs ⇒ Array<Item>
Item which includes “nav” as one of
properties
.
Methods included from Inspector::PublicationModel
Constructor Details
#initialize ⇒ Manifest
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
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/epub/publication/package/manifest.rb', line 13 def id @id end |
#package ⇒ Object
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.
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?
74 75 76 |
# File 'lib/epub/publication/package/manifest.rb', line 74 def [](item_id) @items[item_id] end |
#cover_image ⇒ Item?
Returns 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_item ⇒ 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_nav ⇒ Object
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 |
#items ⇒ Object
68 69 70 |
# File 'lib/epub/publication/package/manifest.rb', line 68 def items @items.values end |
#nav ⇒ Item?
Returns the first item of #navs.
44 45 46 |
# File 'lib/epub/publication/package/manifest.rb', line 44 def nav navs.first end |
#navs ⇒ Array<Item>
Returns 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 |