Class: AbiCoderRb::Tuple

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(inner_types) ⇒ Tuple

Returns a new instance of Tuple.



176
177
178
# File 'lib/abi_coder_rb/type/types.rb', line 176

def initialize(inner_types)
  @inner_types = inner_types
end

Instance Attribute Details

#inner_typesObject (readonly)

Returns the value of attribute inner_types.



174
175
176
# File 'lib/abi_coder_rb/type/types.rb', line 174

def inner_types
  @inner_types
end

Instance Method Details

#==(other) ⇒ Object



195
196
197
# File 'lib/abi_coder_rb/type/types.rb', line 195

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

#formatObject



191
192
193
# File 'lib/abi_coder_rb/type/types.rb', line 191

def format
  "(#{@inner_types.map(&:format).join(",")})"
end

#sizeObject



180
181
182
183
184
185
186
187
188
189
# File 'lib/abi_coder_rb/type/types.rb', line 180

def size
  s = 0
  has_dynamic = false
  @inner_types.each do |type|
    ts = type.size
    has_dynamic ||= ts.nil?
    s += ts unless ts.nil?
  end
  has_dynamic ? nil : s
end