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(archive = nil) ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
256 257 258 |
# File 'lib/epub/maker/publication.rb', line 256 def content @content end |
#content_file ⇒ Object
Returns the value of attribute content_file.
256 257 258 |
# File 'lib/epub/maker/publication.rb', line 256 def content_file @content_file end |
Instance Method Details
#edit ⇒ Object
Save document into EPUB archive when block ended
277 278 279 280 |
# File 'lib/epub/maker/publication.rb', line 277 def edit yield if block_given? save end |
#edit_with_nokogiri {|Nokgiri::XML::Document| ... } ⇒ Object
Save document into EPUB archive at end of block
294 295 296 297 298 299 |
# File 'lib/epub/maker/publication.rb', line 294 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
284 285 286 287 288 289 290 |
# File 'lib/epub/maker/publication.rb', line 284 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(archive = nil) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/epub/maker/publication.rb', line 260 def save(archive=nil) if archive if content archive.add_or_replace_buffer entry_name, content elsif content_file archive.add_or_replace_file entry_name, content_file else raise 'no content nor content_file' end else Zip::Archive.open manifest.package.book.epub_file do |archive| save archive end end end |