Class: Etheruby::Encoders::DynamicArray
- Defined in:
- lib/etheruby/encoders/arrays.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
- #decode ⇒ Object
- #encode ⇒ Object
-
#initialize(_type, _data) ⇒ DynamicArray
constructor
A new instance of DynamicArray.
- #to_s ⇒ Object
Constructor Details
#initialize(_type, _data) ⇒ DynamicArray
Returns a new instance of DynamicArray.
69 70 71 72 |
# File 'lib/etheruby/encoders/arrays.rb', line 69 def initialize(_type, _data) super(_data) @type = _type end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
67 68 69 |
# File 'lib/etheruby/encoders/arrays.rb', line 67 def type @type end |
Instance Method Details
#decode ⇒ Object
83 84 85 86 87 |
# File 'lib/etheruby/encoders/arrays.rb', line 83 def decode size, taken = Uint.new(data[0..63]).decode v, s = StaticArray.new(type, size, data[64..data.length]).decode return v, s+taken end |
#encode ⇒ Object
78 79 80 81 |
# File 'lib/etheruby/encoders/arrays.rb', line 78 def encode Uint.new(data.count).encode + \ StaticArray.new(type, data.count, data).encode end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/etheruby/encoders/arrays.rb', line 74 def to_s encode end |