lib/epub/publication/package/spine.rb in epub-parser-0.1.4 vs lib/epub/publication/package/spine.rb in epub-parser-0.1.5

- old
+ new

@@ -1,16 +1,20 @@ module EPUB module Publication class Package class Spine + include Inspector::PublicationModel attr_accessor :package, :id, :toc, :page_progression_direction attr_reader :itemrefs + def initialize + @itemrefs = [] + end + # @return self def <<(itemref) - @itemrefs ||= [] itemref.spine = self @itemrefs << itemref self end @@ -37,16 +41,20 @@ PAGE_SPREAD_PROPERTIES = ['left'.freeze, 'right'.freeze].freeze PAGE_SPREAD_PREFIX = 'page-spread-'.freeze attr_accessor :spine, :idref, :linear, :id, :properties - alias linear? linear def initialize @properties = [] end + # @return [true|false] + def linear? + !! linear + end + # @return [Package::Manifest::Item] item referred by this object def item @item ||= @spine.package.manifest[idref] end @@ -54,12 +62,14 @@ self.idref = item.id item end def ==(other) - [:spine, :idref, :linear, :id].all? {|meth| + [:spine, :idref, :id].all? {|meth| self.__send__(meth) == other.__send__(meth) - } and (other.properties - properties).empty? + } and + (linear? == other.linear?) and + (other.properties - properties).empty? end # @return ["left", "right", nil] def page_spread property = properties.find {|prop| prop.start_with? PAGE_SPREAD_PREFIX}