class ZipContainer::Dir
This class represents a ZipContainer
in directory format. See the OCF and UCF specifications for more details.
This class provides most of the facilities of the standard ::Dir
class. Please also consult the ruby Dir documentation alongside these pages.
There are code examples available with the source code of this library.
Public Class Methods
Source
# File lib/zip-container/dir.rb 68 def self.create(pathname, mimetype) 69 ::Dir.mkdir(pathname) unless ::File.directory?(pathname) 70 ::File.write(::File.join(pathname, MIMETYPE_FILE), mimetype) 71 72 # Now open the newly created container. 73 c = new(pathname) 74 75 if block_given? 76 begin 77 yield c 78 ensure 79 c.close 80 end 81 end 82 83 c 84 end
Create a new (or convert an existing) directory as a ZipContainer
with the specified mimetype.
Public Instance Methods
Source
# File lib/zip-container/dir.rb 171
Equal to ::Dir.each
Source
# File lib/zip-container/dir.rb 97 def read(name = nil) 98 return @container.read if name.nil? 99 100 ::File.read(full_path(name)) 101 end
Provides compatibility between directory and zip containers. If called without any parameters it acts like ::Dir.read but if called with a path then it acts like Zip::File#read.
Please see the documentation of the relevant method for more details.