Class: RIO::ZipFile::Wrap::Stream::Root

Inherits:
Object
  • Object
show all
Defined in:
lib/rio/ext/zipfile/wrap.rb

Instance Method Summary collapse

Constructor Details

#initialize(zipfile) ⇒ Root

Returns a new instance of Root.



71
72
73
74
75
76
77
# File 'lib/rio/ext/zipfile/wrap.rb', line 71

def initialize(zipfile)
  @zipfile = zipfile
  @infs = RIO::ZipFile::InFile::FS.new(@zipfile)
  #puts @zipfile.methods.sort
  @topents = get_topents_
  @entidx = 0
end

Instance Method Details

#closeObject



96
97
98
99
# File 'lib/rio/ext/zipfile/wrap.rb', line 96

def close
  p "JERE"
  @zipfile.commit if @zipfile.commit_required?
end

#each(&block) ⇒ Object



91
92
93
94
95
# File 'lib/rio/ext/zipfile/wrap.rb', line 91

def each(&block)
  get_topents_.each { |ent|
    yield ent
  }
end

#get_topents_Object



78
79
80
81
82
83
84
85
# File 'lib/rio/ext/zipfile/wrap.rb', line 78

def get_topents_
  topents = {}
  @zipfile.entries.map{ |ent|
    top = ent.to_s.match(%r|^(/?[^/]+(/)?)|)[1]
    topents[top] = 1 unless topents.has_key?(top)
  }
  topents.keys.map{ |v| rio(RIO::Path::RL.new(v.to_s,{:fs => @infs})) }
end

#readObject



86
87
88
89
90
# File 'lib/rio/ext/zipfile/wrap.rb', line 86

def read
  return nil if @entidx >= @topents.size
  @entidx += 1
  @topents[@entidx-1]
end