1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# Converts hex input to pack("C*") (binary) output. Hex can be any of: # # [65,65,65].binarize #=> "AAA" # Decimal notation # [0x41,0x41,0x41].binarize #=> "AAA" # Hex notation # %w{41 41 41}.binarize #=> "AAA" # Strings of hex notation # [0x41,"41",0x41].binarize #=> "AAA" # Mixed fixnums and strings # "414141".binarize #=> "AAA" # Extension to String, below. self {|x| (x == String) ? x(16) : x}("C*") end end # Converts hex input (string format) to packed output. See Array#binarize. self(/../) end end |
