Class: EDI::Bzip2Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/edi4r.rb

Overview

A simple utility class that fills a need not covered by “zlib”.

It is stripped to the essentials needed here internally. Not recommended for general use! The overhead of starting “bzcat” processes all the time is considerable, binding to a library similar to 'zib' for the BZIP2 format would give much better results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hnd) ⇒ Bzip2Reader

Returns a new instance of Bzip2Reader.


151
152
153
154
# File 'lib/edi4r.rb', line 151

def initialize( hnd )
  @path = hnd.path
  @pipe = IO.popen("bzcat #@path",'r' )
end

Instance Attribute Details

#pathObject

Returns the value of attribute path


149
150
151
# File 'lib/edi4r.rb', line 149

def path
  @path
end

Instance Method Details

#closeObject


165
166
167
# File 'lib/edi4r.rb', line 165

def close
  @pipe.close
end

#read(len = 0) ⇒ Object


156
157
158
# File 'lib/edi4r.rb', line 156

def read( len=0 )
  len==0 ? @pipe.read : @pipe.read( len )
end

#rewindObject


160
161
162
163
# File 'lib/edi4r.rb', line 160

def rewind
  @pipe.close
  @pipe = IO.popen("bzcat #@path",'r' )
end