Class: Zip::ZipEntrySet

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/zip/zip.rb

Overview

:nodoc:all

Instance Method Summary (collapse)

Methods included from Enumerable

#inject, #select_map

Constructor Details

- (ZipEntrySet) initialize(anEnumerable = [])

Returns a new instance of ZipEntrySet



1124
1125
1126
1127
1128
# File 'lib/zip/zip.rb', line 1124

def initialize(anEnumerable = [])
  super()
  @entrySet = {}
  anEnumerable.each { |o| push(o) }
end

Instance Method Details

- (Object) <<(entry) Also known as: push



1134
1135
1136
# File 'lib/zip/zip.rb', line 1134

def <<(entry)
  @entrySet[entry.to_s] = entry
end

- (Object) ==(other)



1161
1162
1163
1164
# File 'lib/zip/zip.rb', line 1161

def == (other)
  return false unless other.kind_of?(ZipEntrySet)
  return @entrySet == other.entrySet      
end

- (Object) delete(entry)



1144
1145
1146
# File 'lib/zip/zip.rb', line 1144

def delete(entry)
  @entrySet.delete(entry.to_s) ? entry : nil
end

- (Object) dup

deep clone



1157
1158
1159
# File 'lib/zip/zip.rb', line 1157

def dup
  newZipEntrySet = ZipEntrySet.new(@entrySet.values.map { |e| e.dup })
end

- (Object) each(&aProc)



1148
1149
1150
# File 'lib/zip/zip.rb', line 1148

def each(&aProc)
  @entrySet.values.each(&aProc)
end

- (Object) entries



1152
1153
1154
# File 'lib/zip/zip.rb', line 1152

def entries
  @entrySet.values
end

- (Object) glob(pattern, flags = File::FNM_PATHNAME|File::FNM_DOTMATCH)



1170
1171
1172
1173
1174
1175
# File 'lib/zip/zip.rb', line 1170

def glob(pattern, flags = File::FNM_PATHNAME|File::FNM_DOTMATCH)
  entries.select { 
	|entry| 
	File.fnmatch(pattern, entry.name.chomp('/'), flags) 
  } 
end

- (Boolean) include?(entry)

Returns:

  • (Boolean)


1130
1131
1132
# File 'lib/zip/zip.rb', line 1130

def include?(entry)
  @entrySet.include?(entry.to_s)
end

- (Object) parent(entry)



1166
1167
1168
# File 'lib/zip/zip.rb', line 1166

def parent(entry)
  @entrySet[entry.parent_as_string]
end

- (Object) size Also known as: length



1139
1140
1141
# File 'lib/zip/zip.rb', line 1139

def size
  @entrySet.size
end