Class: Distillery::Archiver::Archive
- Inherits:
-
Object
- Object
- Distillery::Archiver::Archive
- Includes:
- Enumerable
- Defined in:
- lib/distillery/archiver/archive.rb
Overview
Allow archive file processing
All the operations are forwarded to an Distillery::Archiver instance which is able to process the selected archive file.
Instance Method Summary collapse
-
#delete!(entry) ⇒ Boolean
Delete the entry from the archive.
-
#each {|entry, io| ... } ⇒ self, Enumerator
Iterate over each archive entry.
-
#empty? ⇒ Boolean
Is the archive emtpy?.
-
#entries ⇒ Array<String>
List of entries for the archive.
-
#initialize(file) ⇒ Archive
constructor
Returns a new instance of Archive.
-
#reader(entry) {|io| ... } ⇒ Object
Allow to perform read operation on an archive entry.
-
#writer(entry) {|io| ... } ⇒ Object
Allow to perform write operation on an archive entry.
Constructor Details
#initialize(file) ⇒ Archive
Returns a new instance of Archive.
21 22 23 24 25 26 27 28 |
# File 'lib/distillery/archiver/archive.rb', line 21 def initialize(file) @file = file @archiver = Archiver.for_file(file) if @archiver.nil? raise ArchiverNotFound, "no archiver avalaible for this file" end end |
Instance Method Details
#delete!(entry) ⇒ Boolean
Delete the entry from the archive
94 95 96 |
# File 'lib/distillery/archiver/archive.rb', line 94 def delete!(entry) @archiver.delete!(@file, entry) end |
#each {|entry, io| ... } ⇒ self, Enumerator
Iterate over each archive entry
38 39 40 41 |
# File 'lib/distillery/archiver/archive.rb', line 38 def each(&block) @archiver.each(@file, &block) self end |
#empty? ⇒ Boolean
Is the archive emtpy?
57 58 59 |
# File 'lib/distillery/archiver/archive.rb', line 57 def empty? @archiver.empty?(@file) end |
#entries ⇒ Array<String>
List of entries for the archive
48 49 50 |
# File 'lib/distillery/archiver/archive.rb', line 48 def entries @archiver.entries(@file) end |
#reader(entry) {|io| ... } ⇒ Object
Allow to perform read operation on an archive entry
70 71 72 |
# File 'lib/distillery/archiver/archive.rb', line 70 def reader(entry, &block) @archiver.reader(@file, entry, &block) end |
#writer(entry) {|io| ... } ⇒ Object
Allow to perform write operation on an archive entry
83 84 85 |
# File 'lib/distillery/archiver/archive.rb', line 83 def writer(entry, &block) @archiver.writer(@file, entry, &block) end |