File: bz2.rd

package info (click to toggle)
libbz2-ruby 0.2.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 136 kB
  • ctags: 246
  • sloc: ansic: 1,436; ruby: 663; makefile: 63
file content (240 lines) | stat: -rw-r--r-- 6,870 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
=begin

bz2 is an extension to use libbzip2 from ruby

=== Module function

--- bzip2(str, blocks = 9, work = 0)
--- compress(str, blocks = 9, work = 0)
    Compress the String ((|str|))

    ((|blocks|)) specifies the block size to be used for compression.
    It should be a value between 1 and 9 inclusive, and the actual block
    size used is 100000 x this value

    ((|work|)) controls how the compression phase behaves when presented
    with worst case, highly repetitive, input data. 

    You should set this parameter carefully; too low, and many inputs
    will be handled by the fallback algorithm and so compress rather
    slowly, too high, and your average-to-worst case compression times
    can become very large.

    Allowable values range from 0 to 250 inclusive. 0 is a special case,
    equivalent to using the default value of 30.

    The default value of 30 gives reasonable behaviour over a wide
    range of circumstances.

--- bunzip2(str, small = Qfalse)
--- uncompress(str, small = Qfalse)
    Uncompress the String ((|str|))

    If ((|small|)) is ((|true|)), the library will use an alternative 
    decompression algorithm which uses less memory but at the cost of
    decompressing more slowly

== BZ2::Writer

=== Class methods

--- allocate
    allocate a new ((|BZ2::Writer|))

--- new(object = nil, mode = "w", blocks = 9, work = 0)
    Create a new ((|BZ2::Writer|)) associated with ((|object|)).

    ((|object|)) must respond to ((|write|)), or must be ((|nil|))
    in this case the compressed string is returned when ((|flush|))
    is called

    See ((|initialize|)) for ((|blocks|)) and ((|work|))

--- open(filename, mode = "w", blocks = 9, work = 0) {|bz2| ... }
    Call Kernel#open(filename), associate it a new ((|BZ2::Writer|))
    and call the associated block if given.

    The bz2 object is closed at the end of the block

    See ((|initialize|)) for ((|blocks|)) and ((|work|))

=== Methods

--- close
    Terminate the compression.

--- close!
    Terminate the compression and close the associated object

--- finish
--- flush
    Flush the data and terminate the compression, the object can be re-used
    to store another compressed string

--- initialize(object = nil, blocks = 9, work = 0)
    If ((|object|)) is nil then the compression will be made in
    a String which is returned when ((|close|)) or ((|flush|)) is called

    Otherwise ((|object|)) must respond to ((|write(str)|))

    ((|blocks|)) specifies the block size to be used for compression.
    It should be a value between 1 and 9 inclusive, and the actual block
    size used is 100000 x this value

    ((|work|)) controls how the compression phase behaves when presented
    with worst case, highly repetitive, input data. 

    You should set this parameter carefully; too low, and many inputs
    will be handled by the fallback algorithm and so compress rather
    slowly, too high, and your average-to-worst case compression times
    can become very large.

    Allowable values range from 0 to 250 inclusive. 0 is a special case,
    equivalent to using the default value of 30.

    The default value of 30 gives reasonable behaviour over a wide
    range of circumstances.

--- <<(object)
    Writes ((|object|)). ((|object|)) will be converted to a string using
    to_s

--- print(object = $_, ...)
    Writes the given object(s)

--- printf(format, object = $_, ...)
    Formats and writes the given object(s)

--- putc(char)
    Writes the given character

--- puts(object, ...)
    Writes the given objects 

--- to_io
    return the associated object

--- write(str)
    Write the string ((|str|))

== BZ2::Reader

 Included modules : Enumerable

=== Class methods

--- allocate
    allocate a new ((|BZ2::Reader|))

--- foreach(filename, separator = $/) {|line| ... }
    Uncompress the file and call the block for each line, where
    lines are separated by ((|separator|))

--- new(object, small = false)
    Associate a new bz2 reader with ((|object|)). ((|object|)) must
    respond to ((|read|))

    See ((|initialize|)) for ((|small|))

--- open(filename, small = false) {|bz2| ... }
    Call Kernel#open(filename), and associate it a new ((|BZ2::Reader|)).
    The bz2 object is passed as an argument to the block.

    The object is closed at the end of the block

    See ((|initialize|)) for ((|small|))

--- readlines(filename, separator = $/)
    Uncompress the file and reads the entire file as individual lines,
    and returns those lines in an array. Lines are separated by 
    ((|separator|))

=== Methods

--- initialize(object, small = false)
    object must be a String which contains compressed data, or an
    object which respond to ((|read(size)|))

    If ((|small|)) is ((|true|)), the library will use an alternative 
    decompression algorithm which uses less memory but at the cost of
    decompressing more slowly

--- close
    Terminate the uncompression and close the bz2

--- close!
    Terminate the uncompression, close the bz2 and the associated object

--- closed?
    Return true if the file is closed

--- each(separator = $/) {|line| ... }
--- each_line(separator = $/) {|line| ... }
    Execute the block for each line, where lines
    are separated by the optional ((|separator|))

--- eof
    Return true at end of file

--- eoz
    "End Of Zip". Return true at the end of the zip component

--- finish
    Terminate the uncompression of the current zip component, and keep the
    bz2 active (to read another zip component)

--- getc
    Get the next 8-bit byte (0..255). Returns nil if called
    at end of file.

--- gets(separator = $/)
    Reads the next line; lines are separated by ((|separator|)).
    Returns nil if called at end of file.

--- lineno
    Return the current line number

--- lineno=(num)
    Manually sets the current line number to the given value

--- read(number)
    Read at most ((|number|)) characters
    Returns nil if called at end of file

--- readline(separator = $/)
    Reads the next line; lines are separated by ((|separator|)).
    Raise an error at end of file
     
--- readlines(separator = $/)
    Reads all of the lines, and returns them in anArray. Lines
    are separated by the optional ((|separator|))

--- to_io
    return the associated object

--- ungetc(char)
    Push back one character

--- ungets(str)
    Push back the string

--- unused
    Return the String read by ((|BZ2::Reader|)) but not used in the 
    uncompression

--- unused=(str)
    Initialize the uncompression with the String ((|str|))

== Exceptions

=== BZ2::ConfigError < Fatal
  Indicates that the library has been improperly compiled on your platform

=== BZ2::Error < ::IOError
 Exception raised by BZ2

=== BZ2::EOZError < BZ2::Error
 "End of Zip" exception : compressed file finishes before the logical 
  end of stream is detected

=end