Class: AbiCoderRb::Int

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

Overview

class FixedBytes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(bits = 256) ⇒ Int

Returns a new instance of Int.



91
92
93
# File 'lib/abi_coder_rb/types.rb', line 91

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

Instance Attribute Details

#bitsObject (readonly)

Returns the value of attribute bits.



89
90
91
# File 'lib/abi_coder_rb/types.rb', line 89

def bits
  @bits
end

Instance Method Details

#==(other) ⇒ Object



104
105
106
# File 'lib/abi_coder_rb/types.rb', line 104

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

#formatObject



100
101
102
# File 'lib/abi_coder_rb/types.rb', line 100

def format
  "int#{@bits}"
end

#sizeObject

note: always uses 32 bytes (with padding)



96
97
98
# File 'lib/abi_coder_rb/types.rb', line 96

def size
  32
end