Class: ABI::FixedArray

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

Overview

class Array

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#dynamic?, parse

Constructor Details

#initialize(subtype, dim) ⇒ FixedArray

Returns a new instance of FixedArray.



115
116
117
118
# File 'lib/abicoder/types.rb', line 115

def initialize( subtype, dim )
  @subtype = subtype
  @dim      = dim
end

Instance Attribute Details

#dimObject (readonly)

Returns the value of attribute dim.



114
115
116
# File 'lib/abicoder/types.rb', line 114

def dim
  @dim
end

#subtypeObject (readonly)

Returns the value of attribute subtype.



113
114
115
# File 'lib/abicoder/types.rb', line 113

def subtype
  @subtype
end

Instance Method Details

#==(another_type) ⇒ Object



124
125
126
127
128
# File 'lib/abicoder/types.rb', line 124

def ==(another_type)
    another_type.kind_of?( FixedArray ) &&
      @dim == another_type.dim &&
      @subtype == another_type.subtype
end

#formatObject



123
# File 'lib/abicoder/types.rb', line 123

def format() "#{@subtype.format}[#{@dim}]"; end

#sizeObject



120
121
122
# File 'lib/abicoder/types.rb', line 120

def size
   @subtype.dynamic? ? nil : @dim * subtype.size
end