lib/epub/publication/package/manifest.rb in epub-parser-0.0.4 vs lib/epub/publication/package/manifest.rb in epub-parser-0.0.5

- old
+ new

@@ -5,17 +5,16 @@ module Publication class Package class Manifest attr_accessor :package, :id - attr_reader :items # syntax sugar for #items.<< def <<(item) - @items ||= [] + @items ||= {} item.manifest = self - @items << item + @items[item.id] = item end # syntax sugar def navs items.selector {|i| i.properties.include? 'nav'} @@ -27,11 +26,15 @@ def cover_image items.selector {|i| i.properties.include? 'cover-image'}.first end + def items + @items.collect {|id, item| item} + end + def [](item_id) - items.selector {|item| item.id == item_id}.first + @items[item_id] end class Item attr_accessor :manifest, :id, :href, :media_type, :fallback, :properties, :media_overlay,