Sha256: d32b74ac6c497fa3612262742a10ddce73d570bacdbb6f4e58e2c98ce4a8132f
Contents?: true
Size: 1.46 KB
Versions: 7
Compression:
Stored size: 1.46 KB
Contents
module Zip class ZipEntrySet #:nodoc:all include Enumerable def initialize(anEnumerable = []) super() @entrySet = {} anEnumerable.each { |o| push(o) } end def include?(entry) @entrySet.include?(to_key(entry)) end def find_entry(entry) @entrySet[to_key(entry)] end def <<(entry) @entrySet[to_key(entry)] = entry end alias :push :<< def size @entrySet.size end alias :length :size def delete(entry) @entrySet.delete(to_key(entry)) ? entry : nil end def each(&aProc) @entrySet.values.each(&aProc) end def entries @entrySet.values end # deep clone def dup ZipEntrySet.new(@entrySet.values.map { |e| e.dup }) end def ==(other) return false unless other.kind_of?(ZipEntrySet) @entrySet == other.entrySet end def parent(entry) @entrySet[to_key(entry.parent_as_string)] end def glob(pattern, flags = ::File::FNM_PATHNAME|::File::FNM_DOTMATCH) entries.select do |entry| ::File.fnmatch(pattern, entry.name.chomp('/'), flags) end end #TODO attr_accessor :auto_create_directories protected attr_accessor :entrySet private def to_key(entry) entry.to_s.sub(/\/$/, "") end end end # Copyright (C) 2002, 2003 Thomas Sondergaard # rubyzip is free software; you can redistribute it and/or # modify it under the terms of the ruby license.
Version data entries
7 entries across 7 versions & 2 rubygems