Sha256: a80341caa2851fe5ecff3df6f0373cf77abb6f5b8cf02defc4c163adf2001709

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

class ScbiZcatFile

	def self.gz_file?(file_name)
		res=`file -L "#{File.expand_path(file_name)}"`

		return !res.index('gzip').nil?
	end

	def initialize(file_name)
		@file_name=file_name
		open_file
	end

	def open_file
		cmd="zcat \"#{File.expand_path(@file_name)}\""
		#puts "OPEN: #{cmd}"
		@file = IO.popen(cmd)
		#@file.close_write
		@eof=false
	end

	def readline
		begin
		res = @file.readline
		rescue IOError
			close
		end

		return res
	end

	def eof?
		@file.eof?
	end

	def eof
		eof?
	end

	def close
		#@io.finish
		@file.close if !@file.closed?
	end

	def rewind
		close
		open_file
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scbi_zcat-0.0.2 lib/scbi_zcat/scbi_zcat_file.rb