Project

huffify

0.0
The project is in a healthy, maintained state
Huffify is a Ruby gem that provides functionality to encode and decode text data using Huffman encoding, a lossless data compression algorithm. Huffman encoding efficiently compresses data by assigning shorter codes to more frequent symbols and longer codes to less frequent symbols.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.1.0
 Project Readme

Huffify

Huffify is a Ruby gem that provides functionality to encode and decode text data using Huffman encoding, a lossless data compression algorithm. Huffman encoding efficiently compresses data by assigning shorter codes to more frequent symbols and longer codes to less frequent symbols.

Installation

To install the gem, add this line to your application's Gemfile:

gem 'huffify'

Then execute:

bundle install

Or install it yourself as:

gem install huffify

Usage

Basic Encoding and Decoding

Here's how you can use the gem to encode and decode a string using Huffman encoding:

require 'huffify'
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

result = Huffify::encode(text)

decoded_text = Huffify::decode(result[:encoded_text], result[:huffman_tree])

decoded_text == text  # true

License

The gem is available as open source under the terms of the MIT License.