Class: Zipping::StreamMeter
- Inherits:
-
Object
- Object
- Zipping::StreamMeter
- Defined in:
- lib/zipping.rb
Overview
Output stream wrapper that measures size of stream passing through.
Instance Attribute Summary collapse
-
#crc ⇒ Object
readonly
Returns the value of attribute crc.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(output_stream) ⇒ StreamMeter
constructor
A new instance of StreamMeter.
Constructor Details
#initialize(output_stream) ⇒ StreamMeter
Returns a new instance of StreamMeter.
76 77 78 79 80 |
# File 'lib/zipping.rb', line 76 def initialize(output_stream) @output_stream = output_stream @size = 0 @crc = Zlib.crc32 end |
Instance Attribute Details
#crc ⇒ Object (readonly)
Returns the value of attribute crc.
87 88 89 |
# File 'lib/zipping.rb', line 87 def crc @crc end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
86 87 88 |
# File 'lib/zipping.rb', line 86 def size @size end |
Instance Method Details
#<<(data) ⇒ Object
81 82 83 84 85 |
# File 'lib/zipping.rb', line 81 def << (data) @size += data.length @crc = Zlib.crc32 data, @crc @output_stream << data end |