Ruby debase64 then work on bit data

Soldato
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
Hey I am working on a project in Ruby at the moment. I have some Base64 field in a database that I can decode but then the result is a series of binary data where each bit is a boolean value like 00000000010000100000 and I need to tie each of these values up to a table I have of values to see which values are set or not.

However I can't seem to handle the data in Ruby, I can put it into an array of bytes but that's about it. Does anyone know how I can deal with it bit by bit?
 
I have never looked ta Ruby, so there may be a better way, but the simple solution is to have a loop and each time round AND (& symbol in Ruby) the data with 2 x the counter value. That will give zero if the bit isn't set and non zero (twice the counter) if it is.
 
Back
Top Bottom