class Archive::Ar::Reader
Public Class Methods
new(source, options)
click to toggle source
# File lib/archive/ar/reader.rb, line 4 def initialize(source, options) @source = source @options = options @format = Archive::Ar::Format::BSD end
Public Instance Methods
each(full = false) { |*(records)| ... }
click to toggle source
# File lib/archive/ar/reader.rb, line 16 def each(full = false, &block) case @source when IO parse(@source, full); @source.rewind else File.open(@source, 'r') { |f| parse(f, full) } end @index.each { |path| yield *(@records[path]) } end
extract(dest_dir, options)
click to toggle source
# File lib/archive/ar/reader.rb, line 10 def extract(dest_dir, options) each do |header, data| @format.extract_file(dest_dir, header, data, options) end end
parse(io, full = false)
click to toggle source
# File lib/archive/ar/reader.rb, line 27 def parse(io, full = false) @index = [] @records = {} @format.read_global_header(io) until io.eof? header = @format.read_header(io) size = header[:size] name = header[:name] @index << name @records[name] = [header, io.read(size)] # Data sections are 2 byte aligned if size % 2 == 1 io.read(1) end end @records end