HEXADECIMAL string to Binary and Binary to decimal in log-stash using ruby filter

I am working with logstash and I am using ruby filter to change HEX to decimal which works fine for one set of data. What I use for this is ;

ruby{
code => "event.set('xxx', event.get('xx').hex)"
}

I am looking for something similar that will convert HEX to binary then also convert it to decimal after I grok against patterm.The reason I need to do this is because I am picking uneven bits from the hex values e.g

Hex string - "ABC" BINARY - "101010111100"

Then I will use GROK to only pick the first three bits "101" and convert to decimal field which is the value I want , and also for example the next "010" to another field. I am just after help with the two conversions.Not Grok

I have answered the question you asked on StackOverflow. Please mark it as an answer if it works for you.

I am having a look and testing it out. will respond and mark as answered or ask if any issues. really appreciate your help