Class: Tar::Reader

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/tar/reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, **encoding_options) ⇒ Reader

Returns a new instance of Reader.



11
12
13
14
15
# File 'lib/tar/reader.rb', line 11

def initialize(io, **encoding_options)
  @io = io
  @encoding_options = encoding_options
  @header_reader = HeaderReader.new(@io)
end

Instance Method Details

#eachObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tar/reader.rb', line 17

def each
  return to_enum unless block_given?

  loop do
    header = @header_reader.read
    break if header.nil?

    file_reader = FileReader.new(header, @io, **@encoding_options)
    yield file_reader
    file_reader.skip_to_next_record
  end
end