Skip to content

Commit e4d97ab

Browse files
committed
docs: update README.md
1 parent 0a753d2 commit e4d97ab

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ Or install it yourself as:
3434
require 'zstd-ruby'
3535
```
3636

37-
### Simple Compression
37+
### Compression
38+
39+
#### Simple Compression
3840

3941
```ruby
4042
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
4244
```
4345

44-
### Compression using Dictionary
46+
#### Compression with Dictionary
4547
```ruby
4648
# 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'))
4850
```
4951

50-
### Streaming Compression
52+
#### Streaming Compression
5153
```ruby
5254
stream = Zstd::StreamingCompress.new
5355
stream << "abc" << "def"
@@ -66,7 +68,7 @@ res << stream.compress("def")
6668
res << stream.finish
6769
```
6870

69-
### Streaming Compression using Dictionary
71+
#### Streaming Compression with Dictionary
7072
```ruby
7173
stream = Zstd::StreamingCompress.new(dict: IO.read('dictionary_file'))
7274
stream << "abc" << "def"
@@ -75,19 +77,30 @@ stream << "ghi"
7577
res << stream.finish
7678
```
7779

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
7992

8093
```ruby
8194
data = Zstd.decompress(compressed_data)
8295
```
8396

84-
### Decomporession using Dictionary
97+
#### Decompression with Dictionary
8598
```ruby
8699
# 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'))
88101
```
89102

90-
### Streaming Decompression
103+
#### Streaming Decompression
91104
```ruby
92105
cstr = "" # Compressed data
93106
stream = Zstd::StreamingDecompress.new
@@ -96,7 +109,7 @@ result << stream.decompress(cstr[0, 10])
96109
result << stream.decompress(cstr[10..-1])
97110
```
98111

99-
### Streaming Decompression using dictionary
112+
#### Streaming Decompression with dictionary
100113
```ruby
101114
cstr = "" # Compressed data
102115
stream = Zstd::StreamingDecompress.new(dict: IO.read('dictionary_file'))

0 commit comments

Comments
 (0)