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
308 309 310 |
# File 'lib/bindery/formats/epub.rb', line 308 def self.extended(obj) obj.divisions.each{|division| division.extend DivisionMethods} end |
Instance Method Details
#depth ⇒ Object
320 321 322 |
# File 'lib/bindery/formats/epub.rb', line 320 def depth (divisions.map(&:depth) + [0]).max + 1 end |
#epub_id ⇒ Object
312 313 314 |
# File 'lib/bindery/formats/epub.rb', line 312 def epub_id @epub_id ||= File.stemname(file) end |
#epub_output_file ⇒ Object
316 317 318 |
# File 'lib/bindery/formats/epub.rb', line 316 def epub_output_file @epub_output_file ||= "#{epub_id}.xhtml" end |
#write_item(xm) ⇒ Object
324 325 326 327 328 329 |
# File 'lib/bindery/formats/epub.rb', line 324 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
331 332 333 334 |
# File 'lib/bindery/formats/epub.rb', line 331 def write_itemref(xm) xm.itemref('idref' => epub_id) divisions.each{|div| div.write_itemref(xm)} end |
#write_navpoint(xm, play_order) ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/bindery/formats/epub.rb', line 336 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 |