pack and unpack in ruby

Written on March 31, 2015

I still enjoy how complex operations become simple when using ruby:

module Converter
  def self.to_ascii(hex)
    return [hex].pack("H*")
  end

  def self.to_hex(ascii)
    return ascii.unpack('H*')[0]
  end
end