Class: AbiCoderRb::Uint

Inherits:
Type
  • Object
show all
Defined in:
lib/abi_coder_rb/types.rb

Overview

class Int

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(bits = 256) ⇒ Uint

Returns a new instance of Uint.



112
113
114
# File 'lib/abi_coder_rb/types.rb', line 112

def initialize(bits = 256)
  @bits = bits # in bits (8,16,...256)
end

Instance Attribute Details

#bitsObject (readonly)

Returns the value of attribute bits.



110
111
112
# File 'lib/abi_coder_rb/types.rb', line 110

def bits
  @bits
end

Instance Method Details

#==(other) ⇒ Object



125
126
127
# File 'lib/abi_coder_rb/types.rb', line 125

def ==(other)
  other.is_a?(Uint) && @bits == other.bits
end

#formatObject



121
122
123
# File 'lib/abi_coder_rb/types.rb', line 121

def format
  "uint#{@bits}"
end

#sizeObject

note: always uses 32 bytes (with padding)



117
118
119
# File 'lib/abi_coder_rb/types.rb', line 117

def size
  32
end