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.



1099
1100
1101
1102
1103
# File 'lib/zip/zip.rb', line 1099

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

Instance Method Details

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



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

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

#==(other) ⇒ Object



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

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

#delete(entry) ⇒ Object



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

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

#dupObject

deep clone



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

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

#each(&aProc) ⇒ Object



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

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

#entriesObject



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

def entries
  @entrySet.values
end

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



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

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)


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

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

#parent(entry) ⇒ Object



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

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

#sizeObject Also known as: length



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

def size
  @entrySet.size
end