Class: Etheruby::Encoders::Uint

Inherits:
Base
  • Object
show all
Defined in:
lib/etheruby/encoders/int.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Etheruby::Encoders::Base

Instance Method Details

#decodeObject



37
38
39
# File 'lib/etheruby/encoders/int.rb', line 37

def decode
  return data[0..63].to_i(16), 32
end

#encode(pad_to = 64) ⇒ Object



31
32
33
34
35
# File 'lib/etheruby/encoders/int.rb', line 31

def encode(pad_to=64)
  @data = data.to_i if data.is_a? ::String
  raise InvalidFormatForDataError.new("Unsigned integer #{data} < 0") if data < 0
  Int.new(data).encode(pad_to)
end