class Origami::Filter::ASCIIHex


Class representing a filter used to encode and decode data written into hexadecimal.

def decode(string)


_string_:: The data to decode.
Decodes given data writen into upcase hexadecimal representation.
def decode(string)
    input = string.include?(EOD) ? string[0...string.index(EOD)] : string
    digits = input.delete(" \f\t\r\n\0")
    # Ensure every digit is in the hexadecimal charset.
    unless digits =~ /^\h*$/
        digits = digits.match(/^\h*/).to_s
        raise InvalidASCIIHexStringError.new("Invalid characters", input_data: string, decoded_data: [ digits ].pack('H*'))
    end
    [ digits ].pack "H*"
end

def encode(stream)


_stream_:: The data to encode.
Encodes given data into upcase hexadecimal representation.
def encode(stream)
    stream.unpack("H*").join.upcase
end