Class: Etherlite::Types::ArrayDynamic
- Inherits:
-
Base
- Object
- Base
- Etherlite::Types::ArrayDynamic
show all
- Defined in:
- lib/etherlite/types/array_dynamic.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#dynamic?, #fixed?, #size
Constructor Details
Returns a new instance of ArrayDynamic.
5
6
7
8
9
|
# 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
|
Instance Attribute Details
#subtype ⇒ Object
Returns the value of attribute subtype.
3
4
5
|
# File 'lib/etherlite/types/array_dynamic.rb', line 3
def subtype
@subtype
end
|
Instance Method Details
#decode(_connection, _data) ⇒ Object
#encode(_values) ⇒ Object
15
16
17
18
19
20
|
# 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 ⇒ Object
11
12
13
|
# File 'lib/etherlite/types/array_dynamic.rb', line 11
def signature
"#{@subtype.signature}[]"
end
|