https://github.com/dearblue/ruby-extlzham
ruby bindings for lzham
https://github.com/dearblue/ruby-extlzham
Last synced: about 2 months ago
JSON representation
ruby bindings for lzham
- Host: GitHub
- URL: https://github.com/dearblue/ruby-extlzham
- Owner: dearblue
- License: other
- Created: 2017-03-08T12:59:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-08T13:12:07.000Z (about 8 years ago)
- Last Synced: 2025-02-12T11:34:24.678Z (4 months ago)
- Language: C++
- Size: 135 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# encoding:utf-8 ;
# extlzham - ruby binding for LZHAM
This is ruby bindings for compression library
[LZHAM (https://github.com/richgel999/lzham\_codec)](https://github.com/richgel999/lzham_codec).* package name: extlzham
* author: dearblue (mailto:[email protected])
* version: 0.0.1.PROTOTYPE2
* license: 2-clause BSD License ()
* report issue to:
* dependency ruby: ruby-2.0+
* dependency ruby gems: (none)
* dependency libraries: (none)
* bundled external libraries:
* LZHAM-1.0-stable1## HOW TO USE
### Simply process
``` ruby:ruby
# First, load library
require "extlzham"# Prepair data
source = "sample data..." * 50# Directly compression
encdata = LZHAM.encode(source)# Directly decompression
decdata = LZHAM.decode(encdata)# Comparison source and decoded data
p source == decdata
```### Streaming process
``` ruby:ruby
# First, load library
require "extlzham"# Prepair data
source = "sample data..." * 50
sourceio = StringIO.new(source)# streaming compression
LZHAM.encode(dest = StringIO.new("")) do |encoder|
while buf = sourceio.read(50) # Please increase the value if you want to actually use.
encoder << buf
end
# block leave to encoder.close
end# streaming decompression
dest.rewind
decdata = ""
LZHAM.decode(StringIO.new(decdata)) do |decoder|
while buf = dest.read(50)
decoder << buf
end
end# Comparison source and decoded data
p source == decdata
```----
[a stub]