title: Converting a binary value to hexadecimal in Ruby
body: <p>I have a situation where I need to convert a binary value to hex in Ruby. My situation is as follows:</p>
  
  <p>When <code>bin = "0000111"</code>, my output should be: <code>hex = "07"</code>.</p>
  
  <p>When <code>bin = "010001111"</code>, my output should be: <code>hex = "08f"</code>.</p>
  
  <p>Could someone help me out on how to do this? Thanks in advance.</p>