Class: AbiCoderRb::FixedBytes

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

Overview

class Bytes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(length) ⇒ FixedBytes

Returns a new instance of FixedBytes.



70
71
72
# File 'lib/abi_coder_rb/types.rb', line 70

def initialize(length)
  @length = length # in bytes (1,2,...32)
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



68
69
70
# File 'lib/abi_coder_rb/types.rb', line 68

def length
  @length
end

Instance Method Details

#==(other) ⇒ Object



83
84
85
# File 'lib/abi_coder_rb/types.rb', line 83

def ==(other)
  other.is_a?(FixedBytes) && @length == other.length
end

#formatObject



79
80
81
# File 'lib/abi_coder_rb/types.rb', line 79

def format
  "bytes#{@length}"
end

#sizeObject

note: always uses 32 bytes (with padding)



75
76
77
# File 'lib/abi_coder_rb/types.rb', line 75

def size
  32
end