Class: EeePub::OCF
- Inherits:
-
Object
- Object
- EeePub::OCF
- Defined in:
- lib/eeepub/lib/eeepub/ocf.rb
Overview
Class to create OCF
Defined Under Namespace
Classes: Container
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#dir ⇒ Object
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(values) ⇒ OCF
constructor
A new instance of OCF.
-
#save(output_path) ⇒ Object
Save as OCF.
Constructor Details
#initialize(values) ⇒ OCF
Returns a new instance of OCF.
71 72 73 74 75 |
# File 'lib/eeepub/lib/eeepub/ocf.rb', line 71 def initialize(values) values.each do |k, v| self.send(:"#{k}=", v) end end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
62 63 64 |
# File 'lib/eeepub/lib/eeepub/ocf.rb', line 62 def container @container end |
#dir ⇒ Object
Returns the value of attribute dir.
62 63 64 |
# File 'lib/eeepub/lib/eeepub/ocf.rb', line 62 def dir @dir end |
Instance Method Details
#save(output_path) ⇒ Object
Save as OCF
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/eeepub/lib/eeepub/ocf.rb', line 92 def save(output_path) output_path = File.(output_path) FileUtils.chdir(dir) do = 'META-INF' FileUtils.mkdir_p() container.save(File.join(, 'container.xml')) Zippy.create output_path do |zip| zip['mimetype'] = 'application/epub+zip' Dir.glob('**/*').each do |filename| zip[filename] = IO.read(filename) unless File.directory?(filename) end end end end |