Module: PureRubyZip::ZipHelpers

Included in:
ZipFile, ZipFileItem
Defined in:
lib/pure_ruby_zip.rb

Instance Method Summary collapse

Instance Method Details

#find_string(file, string) ⇒ Object



147
148
149
150
151
152
# File 'lib/pure_ruby_zip.rb', line 147

def find_string(file, string)
  search_fifo = ""
  while search_fifo != string
    search_fifo = (search_fifo.length == 4 ? search_fifo[1..-1] : search_fifo) + file.read(1)
  end
end

#read_int(file, bytes) ⇒ Object



144
145
146
# File 'lib/pure_ruby_zip.rb', line 144

def read_int(file, bytes)
  file.read(bytes).codepoints.each.with_index.reduce(0) { |acc, x| acc + x[0] * (256 ** x[1]) }
end

#skip(file, bytes) ⇒ Object



153
154
155
# File 'lib/pure_ruby_zip.rb', line 153

def skip(file, bytes)
  file.read bytes
end