Class: EBPS::Conversion::Oebps::NcxFactory
- Inherits:
-
XmlFactory
- Object
- Factory
- XmlFactory
- EBPS::Conversion::Oebps::NcxFactory
- Defined in:
- lib/ebps/conversion/oebps.rb
Instance Attribute Summary
Attributes inherited from Factory
Instance Method Summary collapse
- #doc_title ⇒ Object
- #head ⇒ Object
-
#initialize(*args) ⇒ NcxFactory
constructor
A new instance of NcxFactory.
- #nav_map ⇒ Object
- #nav_point(play_order, depth, file, id, txt, local_ids = nil, joker = nil) ⇒ Object
- #to_ncx ⇒ Object
Constructor Details
#initialize(*args) ⇒ NcxFactory
Returns a new instance of NcxFactory.
261 262 263 264 265 266 267 268 269 |
# File 'lib/ebps/conversion/oebps.rb', line 261 def initialize *args super @builder.declare! :DOCTYPE, :ncx, :PUBLIC, "-//NISO//DTD ncx 2005-1//EN", "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd" @depth = EBPS.config.max_depth @page_count = @ids.size @sections = 0 end |
Instance Method Details
#doc_title ⇒ Object
270 271 272 273 274 |
# File 'lib/ebps/conversion/oebps.rb', line 270 def doc_title @builder.docTitle do |xml| xml.text EBPS.config.title || @subject.first.title end end |
#head ⇒ Object
275 276 277 278 279 280 281 282 283 |
# File 'lib/ebps/conversion/oebps.rb', line 275 def head @builder.head do |xml| xml. 'name' => 'dtb:uid', 'content' => @uid xml. 'name' => 'dtb:depth', 'content' => @depth xml. 'name' => 'dtb:generator', 'content' => self.class.name xml. 'name' => 'dtb:totalPageCount', 'content' => @page_count xml. 'name' => 'dtb:maxPageNumber', 'content' => @page_count end end |
#nav_map ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/ebps/conversion/oebps.rb', line 284 def nav_map play_order = 0 @builder.navMap do |xml| @ids.each do |id| if id.is_a?(Array) @append_id = false play_order = nav_point play_order, 1, *id end end end end |
#nav_point(play_order, depth, file, id, txt, local_ids = nil, joker = nil) ⇒ Object
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/ebps/conversion/oebps.rb', line 295 def nav_point play_order, depth, file, id, txt, local_ids=nil, joker=nil ## discard duplicate filenames if joker _, file, id, txt, local_ids = file, id, txt, local_ids, joker end play_order += 1 @builder.navPoint 'id' => id, 'playOrder' => play_order do |xml| xml.navLabel do xml.text txt end src = @append_id ? sprintf("%s#%s", file, id) : file xml.content 'src' => src @append_id = true if local_ids && depth < @depth local_ids.each do |local_id| play_order = nav_point play_order, depth + 1, file, *local_id end end end play_order end |
#to_ncx ⇒ Object
316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/ebps/conversion/oebps.rb', line 316 def to_ncx @builder.ncx 'xmlns' => "http://www.daisy.org/z3986/2005/ncx/", 'xml:lang' => EBPS.config.language, 'version' => "2005-1" do |xml| head doc_title # xml.docAuthor could follow here nav_map # possibly we need a page_list # and maybe even a nav_list end end |