Class: ScbiZcatFile
- Inherits:
-
Object
- Object
- ScbiZcatFile
- Defined in:
- lib/scbi_zcat/scbi_zcat_file.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #eof ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(file_name) ⇒ ScbiZcatFile
constructor
A new instance of ScbiZcatFile.
- #open_file ⇒ Object
- #readline ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(file_name) ⇒ ScbiZcatFile
Returns a new instance of ScbiZcatFile.
10 11 12 13 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 10 def initialize(file_name) @file_name=file_name open_file end |
Class Method Details
.gz_file?(file_name) ⇒ Boolean
4 5 6 7 8 |
# 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 |
Instance Method Details
#close ⇒ Object
41 42 43 44 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 41 def close #@io.finish @file.close if !@file.closed? end |
#eof ⇒ Object
37 38 39 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 37 def eof eof? end |
#eof? ⇒ Boolean
33 34 35 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 33 def eof? @file.eof? end |
#open_file ⇒ Object
15 16 17 18 19 20 21 |
# 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 ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 23 def readline begin res = @file.readline rescue IOError close end return res end |
#rewind ⇒ Object
46 47 48 49 |
# File 'lib/scbi_zcat/scbi_zcat_file.rb', line 46 def rewind close open_file end |