Project

bit-packer

0.0
No commit activity in last 3 years
No release in over 3 years
Provides easy declarative way of analyzing the packed bit arrays.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 1.5.2
>= 0.12.1
 Project Readme

BitPacker

bit-packer provides easy declarative way of analyzing the packed bit arrays. See an example:

require "bit-packer"

bp = BitPacker::new(7) do
    number (:alfa) {2}      # length of the entry in bits in block
    boolean :beta
end

p bp.data
# will print out #<struct alfa=3, beta=true>

You can both read from data struct and write to it:

bp.data.boolean = false
bp.data.number = 2

p bp.to_i
# will print out 4

Copyright

Copyright © 2011 – 2015 Martin Poljak. See LICENSE.txt for further details.