Class: GEPUB::Spine::Itemref
- Inherits:
-
Object
- Object
- GEPUB::Spine::Itemref
- Defined in:
- lib/gepub/spine.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](x) ⇒ Object
- #[]=(x, y) ⇒ Object
- #add_property(property) ⇒ Object
-
#initialize(idref, parent = nil, attributes = {}) ⇒ Itemref
constructor
A new instance of Itemref.
- #page_spread_left ⇒ Object
- #page_spread_right ⇒ Object
- #to_xml(builder, opf_version) ⇒ Object
Constructor Details
#initialize(idref, parent = nil, attributes = {}) ⇒ Itemref
Returns a new instance of Itemref.
12 13 14 15 16 17 18 19 20 |
# File 'lib/gepub/spine.rb', line 12 def initialize(idref, parent = nil, attributes = {}) if attributes['properties'].class == String attributes['properties'] = attributes['properties'].split(' ') end @attributes = {'idref' => idref}.merge(attributes) @parent = parent @parent.register_itemref(self) unless @parent.nil? self end |
Class Method Details
Instance Method Details
#[](x) ⇒ Object
29 30 31 |
# File 'lib/gepub/spine.rb', line 29 def [](x) @attributes[x] end |
#[]=(x, y) ⇒ Object
33 34 35 |
# File 'lib/gepub/spine.rb', line 33 def []=(x,y) @attributes[x] = y end |
#add_property(property) ⇒ Object
37 38 39 |
# File 'lib/gepub/spine.rb', line 37 def add_property(property) (@attributes['properties'] ||=[]) << property end |
#page_spread_left ⇒ Object
45 46 47 |
# File 'lib/gepub/spine.rb', line 45 def page_spread_left add_property 'page-spread-left' end |
#page_spread_right ⇒ Object
41 42 43 |
# File 'lib/gepub/spine.rb', line 41 def page_spread_right add_property 'page-spread-right' end |
#to_xml(builder, opf_version) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gepub/spine.rb', line 49 def to_xml(builder, opf_version) attr = @attributes.dup if opf_version.to_f < 3.0 attr.reject!{ |k,v| k == 'properties' } end if !attr['properties'].nil? attr['properties'] = attr['properties'].join(' ') if attr['properties'].size == 0 attr.delete 'properties' end end builder.itemref(attr) end |