Class: Bzip2::Writer
- Inherits:
-
Object
- Object
- Bzip2::Writer
- Defined in:
- lib/bzip2/writer.rb
Overview
A Bzip2::Writer represents a stream which compresses data written to it. It can be constructed with another IO object (a File) which data can be written to. Otherwise, data is all stored internally as a string and can be retrieved via the Bzip2::Writer#flush method
It can both write to files:
writer = Bzip2::Writer.open('file')
writer << data
writer.close
Bzip2::Writer.open('file'){ |f| f << data }
writer = Bzip2::Writer.new File.open('file')
And output data as a string
writer = Bzip2::Writer.new
writer << data
writer.flush # => data compressed via bz2
Instance Method Summary collapse
-
#<<(data) ⇒ Object
Append some data to this buffer, returning the buffer so this method can be chained.
-
#print(*objs) ⇒ Object
Similar to Bzip2::Writer#puts except a newline is not appended after each object appended to this buffer.
-
#printf(format, *ojbs) ⇒ Object
Prints data to this buffer with the specified format.
-
#puts(*objs) ⇒ Object
Adds a number of strings to this buffer.
Instance Method Details
#<<(data) ⇒ Object
40 41 |
# File 'lib/bzip2/writer.rb', line 40 def << data end |
#print(*objs) ⇒ Object
Similar to Bzip2::Writer#puts except a newline is not appended after each object appended to this buffer
53 54 |
# File 'lib/bzip2/writer.rb', line 53 def print *objs end |
#printf(format, *ojbs) ⇒ Object
Prints data to this buffer with the specified format.
59 60 |
# File 'lib/bzip2/writer.rb', line 59 def printf format, *ojbs end |
#puts(*objs) ⇒ Object
Adds a number of strings to this buffer. A newline is also inserted into the buffer after each object
46 47 |
# File 'lib/bzip2/writer.rb', line 46 def puts *objs end |