Class: Zip::EntrySet
- Inherits:
-
Object
- Object
- Zip::EntrySet
- Includes:
- Enumerable
- Defined in:
- lib/zip/entry_set.rb
Overview
:nodoc:all
Instance Attribute Summary collapse
-
#entry_order ⇒ Object
Returns the value of attribute entry_order.
-
#entry_set ⇒ Object
Returns the value of attribute entry_set.
Instance Method Summary collapse
- #<<(entry) ⇒ Object (also: #push)
- #==(other) ⇒ Object
- #delete(entry) ⇒ Object
-
#dup ⇒ Object
deep clone.
- #each ⇒ Object
- #entries ⇒ Object
- #find_entry(entry) ⇒ Object
- #glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB) ⇒ Object
- #include?(entry) ⇒ Boolean
-
#initialize(an_enumerable = []) ⇒ EntrySet
constructor
A new instance of EntrySet.
- #parent(entry) ⇒ Object
- #size ⇒ Object (also: #length)
Constructor Details
#initialize(an_enumerable = []) ⇒ EntrySet
Returns a new instance of EntrySet.
6 7 8 9 10 |
# File 'lib/zip/entry_set.rb', line 6 def initialize(an_enumerable = []) super() @entry_set = {} an_enumerable.each { |o| push(o) } end |
Instance Attribute Details
#entry_order ⇒ Object
Returns the value of attribute entry_order.
4 5 6 |
# File 'lib/zip/entry_set.rb', line 4 def entry_order @entry_order end |
#entry_set ⇒ Object
Returns the value of attribute entry_set.
4 5 6 |
# File 'lib/zip/entry_set.rb', line 4 def entry_set @entry_set end |
Instance Method Details
#<<(entry) ⇒ Object Also known as: push
20 21 22 |
# File 'lib/zip/entry_set.rb', line 20 def <<(entry) @entry_set[to_key(entry)] = entry if entry end |
#==(other) ⇒ Object
51 52 53 54 55 |
# File 'lib/zip/entry_set.rb', line 51 def ==(other) return false unless other.kind_of?(EntrySet) @entry_set.values == other.entry_set.values end |
#delete(entry) ⇒ Object
32 33 34 |
# File 'lib/zip/entry_set.rb', line 32 def delete(entry) entry if @entry_set.delete(to_key(entry)) end |
#dup ⇒ Object
deep clone
47 48 49 |
# File 'lib/zip/entry_set.rb', line 47 def dup EntrySet.new(@entry_set.values.map(&:dup)) end |
#each ⇒ Object
36 37 38 39 40 |
# File 'lib/zip/entry_set.rb', line 36 def each @entry_set = sorted_entries.dup.each do |_, value| yield(value) end end |
#entries ⇒ Object
42 43 44 |
# File 'lib/zip/entry_set.rb', line 42 def entries sorted_entries.values end |
#find_entry(entry) ⇒ Object
16 17 18 |
# File 'lib/zip/entry_set.rb', line 16 def find_entry(entry) @entry_set[to_key(entry)] end |
#glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/zip/entry_set.rb', line 61 def glob(pattern, flags = ::File::FNM_PATHNAME | ::File::FNM_DOTMATCH | ::File::FNM_EXTGLOB) 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
12 13 14 |
# File 'lib/zip/entry_set.rb', line 12 def include?(entry) @entry_set.include?(to_key(entry)) end |
#parent(entry) ⇒ Object
57 58 59 |
# File 'lib/zip/entry_set.rb', line 57 def parent(entry) @entry_set[to_key(entry.parent_as_string)] end |
#size ⇒ Object Also known as: length
26 27 28 |
# File 'lib/zip/entry_set.rb', line 26 def size @entry_set.size end |