@@ -34,20 +34,22 @@ Or install it yourself as:
34
34
require ' zstd-ruby'
35
35
```
36
36
37
- ### Simple Compression
37
+ ### Compression
38
+
39
+ #### Simple Compression
38
40
39
41
``` ruby
40
42
compressed_data = Zstd .compress(data)
41
- compressed_data = Zstd .compress(data, complession_level) # default compression_level is 0
43
+ compressed_data = Zstd .compress(data, level: complession_level) # default compression_level is 3
42
44
```
43
45
44
- ### Compression using Dictionary
46
+ #### Compression with Dictionary
45
47
``` ruby
46
48
# dictionary is supposed to have been created using `zstd --train`
47
- compressed_using_dict = Zstd .compress_using_dict (" " , IO .read(' dictionary_file' ))
49
+ compressed_using_dict = Zstd .compress (" " , dict: IO .read(' dictionary_file' ))
48
50
```
49
51
50
- ### Streaming Compression
52
+ #### Streaming Compression
51
53
``` ruby
52
54
stream = Zstd ::StreamingCompress .new
53
55
stream << " abc" << " def"
@@ -66,7 +68,7 @@ res << stream.compress("def")
66
68
res << stream.finish
67
69
```
68
70
69
- ### Streaming Compression using Dictionary
71
+ #### Streaming Compression with Dictionary
70
72
``` ruby
71
73
stream = Zstd ::StreamingCompress .new (dict: IO .read(' dictionary_file' ))
72
74
stream << " abc" << " def"
@@ -75,19 +77,30 @@ stream << "ghi"
75
77
res << stream.finish
76
78
```
77
79
78
- ### Simple Decompression
80
+ #### Streaming Compression with level and Dictionary
81
+ ``` ruby
82
+ stream = Zstd ::StreamingCompress .new (level: 5 , dict: IO .read(' dictionary_file' ))
83
+ stream << " abc" << " def"
84
+ res = stream.flush
85
+ stream << " ghi"
86
+ res << stream.finish
87
+ ```
88
+
89
+ ### Decompression
90
+
91
+ #### Simple Decompression
79
92
80
93
``` ruby
81
94
data = Zstd .decompress(compressed_data)
82
95
```
83
96
84
- ### Decomporession using Dictionary
97
+ #### Decompression with Dictionary
85
98
``` ruby
86
99
# dictionary is supposed to have been created using `zstd --train`
87
- Zstd .decompress_using_dict (compressed_using_dict, IO .read(' dictionary_file' ))
100
+ Zstd .decompress (compressed_using_dict, dict: IO .read(' dictionary_file' ))
88
101
```
89
102
90
- ### Streaming Decompression
103
+ #### Streaming Decompression
91
104
``` ruby
92
105
cstr = " " # Compressed data
93
106
stream = Zstd ::StreamingDecompress .new
@@ -96,7 +109,7 @@ result << stream.decompress(cstr[0, 10])
96
109
result << stream.decompress(cstr[10 ..- 1 ])
97
110
```
98
111
99
- ### Streaming Decompression using dictionary
112
+ #### Streaming Decompression with dictionary
100
113
``` ruby
101
114
cstr = " " # Compressed data
102
115
stream = Zstd ::StreamingDecompress .new (dict: IO .read(' dictionary_file' ))
0 commit comments