class Etherlite::Types::ArrayFixed

Attributes

length[R]
subtype[R]

Public Class Methods

new(_subtype, _length) click to toggle source
# File lib/etherlite/types/array_fixed.rb, line 5
def initialize(_subtype, _length)
  raise ArgumentError, 'An array can not contain a dynamic type' if _subtype.dynamic?

  @subtype = _subtype
  @length = _length
end

Public Instance Methods

decode(_connection, _data) click to toggle source
# File lib/etherlite/types/array_fixed.rb, line 28
def decode(_connection, _data)
  Etherlite::Support::Array.decode(_connection, [@subtype] * @length, _data)
end
encode(_values) click to toggle source
# File lib/etherlite/types/array_fixed.rb, line 21
def encode(_values)
  raise ArgumentError, "expected an array for #{signature}" unless _values.is_a? Array
  raise ArgumentError, "expected array of length #{@length}" unless _values.length == @length

  Etherlite::Support::Array.encode([@subtype] * @length, _values)
end
signature() click to toggle source
# File lib/etherlite/types/array_fixed.rb, line 12
def signature
  "#{@subtype.signature}[#{@length}]"
end
size() click to toggle source
# File lib/etherlite/types/array_fixed.rb, line 16
def size
  return nil if @subtype.dynamic?
  @subtype.size * @length
end