class ScbiZcatFile

Public Class Methods

gz_file?(file_name) click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 4
def self.gz_file?(file_name)
        res=`file -L "#{File.expand_path(file_name)}"`

        return !res.index('gzip').nil?
end
new(file_name) click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 10
def initialize(file_name)
        @file_name=file_name
        open_file
end

Public Instance Methods

close() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 41
def close
        #@io.finish
        @file.close if !@file.closed?
end
eof() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 37
def eof
        eof?
end
eof?() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 33
def eof?
        @file.eof?
end
open_file() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 15
def open_file
        cmd="zcat \"#{File.expand_path(@file_name)}\""
        #puts "OPEN: #{cmd}"
        @file = IO.popen(cmd)
        #@file.close_write
        @eof=false
end
readline() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 23
def readline
        begin
        res = @file.readline
        rescue IOError
                close
        end

        return res
end
rewind() click to toggle source
# File lib/scbi_zcat/scbi_zcat_file.rb, line 46
def rewind
        close
        open_file
end