class Etherlite::Types::ArrayDynamic
Attributes
subtype[R]
Public Class Methods
new(_subtype)
click to toggle source
# File lib/etherlite/types/array_dynamic.rb, line 5 def initialize(_subtype) raise ArgumentError, 'An array can not contain a dynamic type' if _subtype.dynamic? @subtype = _subtype end
Public Instance Methods
decode(_connection, _data)
click to toggle source
# File lib/etherlite/types/array_dynamic.rb, line 22 def decode(_connection, _data) length = Etherlite::Utils.hex_to_uint(_data[0..63]) Etherlite::Support::Array.decode(_connection, [@subtype] * length, _data[64..-1]) end
encode(_values)
click to toggle source
# File lib/etherlite/types/array_dynamic.rb, line 15 def encode(_values) raise ArgumentError, "expected an array for #{signature}" unless _values.is_a? Array encoded_array = Etherlite::Support::Array.encode([@subtype] * _values.length, _values) Etherlite::Utils.uint_to_hex(_values.length) + encoded_array end
signature()
click to toggle source
# File lib/etherlite/types/array_dynamic.rb, line 11 def signature "#{@subtype.signature}[]" end