Class: EPUB::Publication::Package::Manifest::Item
- Inherits:
-
Object
- Object
- EPUB::Publication::Package::Manifest::Item
- Defined in:
- lib/epub/maker/publication.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#content_file ⇒ Object
Returns the value of attribute content_file.
Instance Method Summary collapse
-
#edit ⇒ Object
Save document into EPUB archive when block ended.
-
#edit_with_nokogiri {|Nokgiri::XML::Document| ... } ⇒ Object
Save document into EPUB archive at end of block.
-
#edit_with_rexml {|REXML::Document| ... } ⇒ Object
Save document into EPUB archive at end of block.
- #save ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
280 281 282 |
# File 'lib/epub/maker/publication.rb', line 280 def content @content end |
#content_file ⇒ Object
Returns the value of attribute content_file.
280 281 282 |
# File 'lib/epub/maker/publication.rb', line 280 def content_file @content_file end |
Instance Method Details
#edit ⇒ Object
Save document into EPUB archive when block ended
302 303 304 305 |
# File 'lib/epub/maker/publication.rb', line 302 def edit yield if block_given? save end |
#edit_with_nokogiri {|Nokgiri::XML::Document| ... } ⇒ Object
Save document into EPUB archive at end of block
319 320 321 322 323 324 |
# File 'lib/epub/maker/publication.rb', line 319 def edit_with_nokogiri doc = Nokogiri.XML(read) yield doc if block_given? self.content = doc.to_xml save end |
#edit_with_rexml {|REXML::Document| ... } ⇒ Object
Save document into EPUB archive at end of block
309 310 311 312 313 314 315 |
# File 'lib/epub/maker/publication.rb', line 309 def edit_with_rexml require 'rexml/document' doc = REXML::Document.new(read) yield doc if block_given? self.content = doc.to_s save end |
#save ⇒ Object
TODO:
Don’t read content from file when content_file
exists. If container adapter is Archive::Zip, it writes content to file twice.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/epub/maker/publication.rb', line 284 def save content_to_save = if content content elsif content_file File.read(content_file) else begin read rescue OCF::PhysicalContainer::NoEntry raise 'no content nor content_file' end end book = manifest.package.book book.container_adapter.write book.epub_file, entry_name, content_to_save end |