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

Returns a new instance of ZipEntrySet.



1103
1104
1105
1106
1107
# File 'lib/zip/zip.rb', line 1103

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

Instance Method Details

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



1113
1114
1115
# File 'lib/zip/zip.rb', line 1113

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

#==(other) ⇒ Object



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

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

#delete(entry) ⇒ Object



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

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

#dupObject

deep clone



1136
1137
1138
# File 'lib/zip/zip.rb', line 1136

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

#each(&aProc) ⇒ Object



1127
1128
1129
# File 'lib/zip/zip.rb', line 1127

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

#entriesObject



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

def entries
  @entrySet.values
end

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



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

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

#include?(entry) ⇒ Boolean

Returns:

  • (Boolean)


1109
1110
1111
# File 'lib/zip/zip.rb', line 1109

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

#parent(entry) ⇒ Object



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

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

#sizeObject Also known as: length



1118
1119
1120
# File 'lib/zip/zip.rb', line 1118

def size
  @entrySet.size
end