Class: Zip::ZipEntrySet

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

Overview

:nodoc:all

Instance Method Summary collapse

Constructor Details

#initialize(anEnumerable = []) ⇒ ZipEntrySet

Returns a new instance of ZipEntrySet.



5
6
7
8
9
# File 'lib/zip/zip_entry_set.rb', line 5

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

Instance Method Details

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



19
20
21
# File 'lib/zip/zip_entry_set.rb', line 19

def <<(entry)
  @entrySet[to_key(entry)] = entry
end

#==(other) ⇒ Object



47
48
49
50
# File 'lib/zip/zip_entry_set.rb', line 47

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

#delete(entry) ⇒ Object



30
31
32
# File 'lib/zip/zip_entry_set.rb', line 30

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

#dupObject

deep clone



43
44
45
# File 'lib/zip/zip_entry_set.rb', line 43

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

#each(&aProc) ⇒ Object



34
35
36
# File 'lib/zip/zip_entry_set.rb', line 34

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

#entriesObject



38
39
40
# File 'lib/zip/zip_entry_set.rb', line 38

def entries
  @entrySet.values
end

#find_entry(entry) ⇒ Object



15
16
17
# File 'lib/zip/zip_entry_set.rb', line 15

def find_entry(entry)
  @entrySet[to_key(entry)]
end

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



56
57
58
59
60
61
62
# File 'lib/zip/zip_entry_set.rb', line 56

def glob(pattern, flags = ::File::FNM_PATHNAME|::File::FNM_DOTMATCH)
  entries.map do |entry|
    next nil unless ::File.fnmatch(pattern, entry.name.chomp('/'), flags)
    yield(entry) if block_given?
    entry
  end.compact
end

#include?(entry) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/zip/zip_entry_set.rb', line 11

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

#parent(entry) ⇒ Object



52
53
54
# File 'lib/zip/zip_entry_set.rb', line 52

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

#sizeObject Also known as: length



24
25
26
# File 'lib/zip/zip_entry_set.rb', line 24

def size
  @entrySet.size
end