Module: Bindery::Formats::Epub::DivisionMethods
- Defined in:
- lib/bindery/formats/epub.rb
Class Method Summary collapse
Instance Method Summary collapse
- #depth ⇒ Object
- #epub_id ⇒ Object
- #epub_output_file ⇒ Object
- #write_item(xm) ⇒ Object
- #write_itemref(xm) ⇒ Object
- #write_navpoint(xm, play_order) ⇒ Object
Class Method Details
.extended(obj) ⇒ Object
306 307 308 |
# File 'lib/bindery/formats/epub.rb', line 306 def self.extended(obj) obj.divisions.each{|division| division.extend DivisionMethods} end |
Instance Method Details
#depth ⇒ Object
318 319 320 |
# File 'lib/bindery/formats/epub.rb', line 318 def depth (divisions.map(&:depth) + [0]).max + 1 end |
#epub_id ⇒ Object
310 311 312 |
# File 'lib/bindery/formats/epub.rb', line 310 def epub_id @epub_id ||= File.stemname(file) end |
#epub_output_file ⇒ Object
314 315 316 |
# File 'lib/bindery/formats/epub.rb', line 314 def epub_output_file @epub_output_file ||= "#{epub_id}.xhtml" end |
#write_item(xm) ⇒ Object
322 323 324 325 326 327 |
# File 'lib/bindery/formats/epub.rb', line 322 def write_item(xm) xm.item('id' => epub_id, 'href' => epub_output_file, 'media-type' => 'application/xhtml+xml') divisions.each{|div| div.write_item(xm)} end |
#write_itemref(xm) ⇒ Object
329 330 331 332 |
# File 'lib/bindery/formats/epub.rb', line 329 def write_itemref(xm) xm.itemref('idref' => epub_id) divisions.each{|div| div.write_itemref(xm)} end |
#write_navpoint(xm, play_order) ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/bindery/formats/epub.rb', line 334 def write_navpoint(xm, play_order) xm.navPoint('class'=>'chapter', 'id'=>epub_id, 'playOrder'=>play_order) { xm.navLabel { xm.text title } xm.content 'src'=>epub_output_file divisions.each do |division| play_order += 1 play_order = division.write_navpoint(xm, play_order) end } play_order end |