Class: RSI::BZip2Serializer
- Inherits:
-
Object
- Object
- RSI::BZip2Serializer
- Defined in:
- lib/rsi/compressed_serializers.rb
Overview
Serializer which performs bzip (de)compression on the output of another base serializer. By default, this sits on a NativeSerializer. This requires BZ2: raa.ruby-lang.org/project/bz2/ .
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
Instance Method Summary collapse
- #dump(obj, stream) ⇒ Object
-
#initialize(base_serializer = NativeSerializer.new()) ⇒ BZip2Serializer
constructor
Pass another Serializer as an argument, if don’t want the default.
- #load(stream) ⇒ Object
Constructor Details
#initialize(base_serializer = NativeSerializer.new()) ⇒ BZip2Serializer
Pass another Serializer as an argument, if don’t want the default.
44 45 46 47 48 49 |
# File 'lib/rsi/compressed_serializers.rb', line 44 def initialize( base_serializer=NativeSerializer.new() ) unless defined? BZ2 raise "The BZ2 module is not loaded (it must be installed and `require`d before this module is used)" end @base = base_serializer end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
42 43 44 |
# File 'lib/rsi/compressed_serializers.rb', line 42 def base @base end |
Instance Method Details
#dump(obj, stream) ⇒ Object
50 51 52 53 |
# File 'lib/rsi/compressed_serializers.rb', line 50 def dump( obj, stream ) w = BZ2::Writer.new( stream ) @base.dump( obj, w ) end |
#load(stream) ⇒ Object
54 55 56 57 |
# File 'lib/rsi/compressed_serializers.rb', line 54 def load( stream ) r = BZ2::Reader.new( stream ) return @base.load( r ) end |