class EPUB::Publication::Package::Spine::Itemref
Constants
- PAGE_SPREAD_PREFIX
- PAGE_SPREAD_PROPERTIES
Attributes
Public Class Methods
Source
# File lib/epub/publication/package/spine.rb, line 50 def initialize @properties = Set.new end
Public Instance Methods
Source
# File lib/epub/publication/package/spine.rb, line 73 def ==(other) [:spine, :idref, :id].all? {|meth| self.__send__(meth) == other.__send__(meth) } and (linear? == other.linear?) and (properties == other.properties) end
Source
# File lib/epub/publication/package/spine.rb, line 64 def item @item ||= @spine.package.manifest[idref] end
@return [Package::Manifest::Item] item referred by this object
Source
# File lib/epub/publication/package/spine.rb, line 68 def item=(item) self.idref = item.id item end
Source
# File lib/epub/publication/package/spine.rb, line 59 def linear? !! linear end
@return [true|false]
Source
# File lib/epub/publication/package/spine.rb, line 82 def page_spread property = properties.find {|prop| prop.start_with? PAGE_SPREAD_PREFIX} property ? property.gsub(/\A#{Regexp.escape(PAGE_SPREAD_PREFIX)}/, '') : nil end
@return [“left”, “right”, nil]
Source
# File lib/epub/publication/package/spine.rb, line 88 def page_spread=(new_value) if new_value.nil? properties.delete_if {|prop| prop.start_with? PAGE_SPREAD_PREFIX} return new_value end raise "Unsupported page-spread property: #{new_value}" unless PAGE_SPREAD_PROPERTIES.include? new_value props_to_be_deleted = (PAGE_SPREAD_PROPERTIES - [new_value]).map {|prop| "#{PAGE_SPREAD_PREFIX}#{prop}"} properties.delete_if {|prop| props_to_be_deleted.include? prop} new_property = "#{PAGE_SPREAD_PREFIX}#{new_value}" properties << new_property unless properties.include? new_property new_value end
@param new_value [“left”, “right”, nil]
Source
# File lib/epub/publication/package/spine.rb, line 54 def properties=(props) @properties = props.kind_of?(Set) ? props : Set.new(props) end