Class | Archive::Tar::Minitar::Input
In: | lib/facets/more/minitar.rb
Parent: | Object

Wraps a Archive::Tar::Minitar::Reader with convenience methods and wrapped stream management; Input only works with random access data streams. See Input::new for details.

### Methods

close each extract_entry new open tar

### Included Modules

Enumerable

### Public Class methods

new(input)

Creates a new Input object. If `input` is a stream object that responds to read), then it will simply be wrapped. Otherwise, one will be created and opened using Kernel#open. When Input#close is called, the stream object wrapped will be closed.

open(input) {|stream| ...}

With no associated block, +Input::open+ is a synonym for +Input::new+. If the optional code block is given, it will be passed the new writer as an argument and the Input object will automatically be closed when the block terminates. In this instance, +Input::open+ returns the value of the block.

### Public Instance methods

close()

Closes the Reader object and the wrapped data stream.

each() {|entry| ...}

Iterates through each entry and rewinds to the beginning of the stream when finished.

extract_entry(destdir, entry) {|:dir, entry.full_name, stats if block_given?| ...}

Extracts the current `entry` to `destdir`. If a block is provided, it yields an `action` Symbol, the full name of the file being extracted (`name`), and a Hash of statistical information (`stats`).

The `action` will be one of:

`:dir`: | The `entry` is a directory.
`:file_start`: | The `entry` is a file; the extract of the file is just beginning.
`:file_progress`: | Yielded every 4096 bytes during the extract of the `entry`.
`:file_done`: | Yielded when the `entry` is completed.

The `stats` hash contains the following keys:

`:current`: | The current total number of bytes read in the `entry`.
`:currinc`: | The current number of bytes read in this read cycle.
`:entry`: | The entry being extracted; this is a Reader::EntryStream, with all methods thereof.

tar()

Returns the Reader object for direct access.

[Validate]