Class: RIO::ZipFile::RootDir
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/rio/ext/zipfile/rootdir.rb
Instance Method Summary
collapse
Constructor Details
#initialize(zipfilepath) ⇒ RootDir
Returns a new instance of RootDir.
36
37
38
39
40
41
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 36
def initialize(zipfilepath)
@zipfilepath = zipfilepath
@zipfile = Zip::ZipFile.new(@zipfilepath)
@topents = get_topents_
@entidx = 0
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
70
71
72
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 70
def method_missing(sym,*args,&block)
@zipfile.__send__(sym,*args,&block)
end
|
Instance Method Details
68
69
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 68
def close
end
|
51
52
53
54
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 51
def commit
@zipfile.commit
@topents = get_topents_
end
|
#each(&block) ⇒ Object
63
64
65
66
67
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 63
def each(&block)
@topents.each { |ent|
yield ent
}
end
|
#get_topents_ ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 42
def get_topents_
topents = {}
@zipfile.entries.map{ |ent|
top = ent.to_s.match(%r|^(/?[^/]+(/)?)|)[1]
topents[top] = ent if top == ent.to_s
}
fs = RIO::ZipFile::FS::InFile.new(@zipfile)
topents.values.map{ |v| rio(RIO::Path::RL.new(v.to_s,{:fs => fs})) }
end
|
55
56
57
58
59
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 55
def read
return nil if @entidx >= @topents.size
@entidx += 1
@topents[@entidx-1]
end
|
60
61
62
|
# File 'lib/rio/ext/zipfile/rootdir.rb', line 60
def rewind
@entidx = 0
end
|