class EthereumContractABI::Decoders::StringDecoder

Public Class Methods

decode(string, num_bytes = nil) click to toggle source
# File lib/ethereum-contract-abi/decoders/string_decoder.rb, line 9
def self.decode(string, num_bytes = nil)
  hex = [string].pack('H*')
  length = IntDecoder.decode(hex.byteslice(0, 32).unpack("H*").first)
  hex.byteslice(32..hex.bytesize).byteslice(0, length).strip
end