Class: AbiCoderRb::Tuple

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

Overview

class FixedArray

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(types) ⇒ Tuple

Returns a new instance of Tuple.



207
208
209
# File 'lib/abi_coder_rb/types.rb', line 207

def initialize(types)
  @types = types
end

Instance Attribute Details

#typesObject (readonly)

Returns the value of attribute types.



205
206
207
# File 'lib/abi_coder_rb/types.rb', line 205

def types
  @types
end

Instance Method Details

#==(other) ⇒ Object



233
234
235
# File 'lib/abi_coder_rb/types.rb', line 233

def ==(other)
  other.is_a?(Tuple) && @types == other.types
end

#formatObject



229
230
231
# File 'lib/abi_coder_rb/types.rb', line 229

def format
  "(#{@types.map { |t| t.format }.join(",")})" ## rebuild minimal string
end

#sizeObject



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/abi_coder_rb/types.rb', line 211

def size
  s = 0
  has_dynamic = false
  @types.each do |type|
    ts = type.size
    if ts.nil?
      # can not return nil here? if wasm
      has_dynamic = true
    else
      s += ts
    end
  end

  return if has_dynamic

  s
end