pack and unpack in ruby

- 1 min

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
comments powered by Disqus
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora