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

#initialize(anEnumerable = []) ⇒ ZipEntrySet



1096
1097
1098
1099
1100
# File 'lib/zip/zip.rb', line 1096

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

Instance Method Details

#<<(entry) ⇒ Object Also known as: push



1106
1107
1108
# File 'lib/zip/zip.rb', line 1106

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

#==(other) ⇒ Object



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

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

#delete(entry) ⇒ Object



1116
1117
1118
# File 'lib/zip/zip.rb', line 1116

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

#dupObject

deep clone



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

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

#each(&aProc) ⇒ Object



1120
1121
1122
# File 'lib/zip/zip.rb', line 1120

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

#entriesObject



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

def entries
  @entrySet.values
end

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



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

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

#include?(entry) ⇒ Boolean



1102
1103
1104
# File 'lib/zip/zip.rb', line 1102

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

#parent(entry) ⇒ Object



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

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

#sizeObject Also known as: length



1111
1112
1113
# File 'lib/zip/zip.rb', line 1111

def size
  @entrySet.size
end