Class: TezosClient::Tools::ConvertToHash::Map

Inherits:
Base
  • Object
show all
Defined in:
lib/tezos_client/tools/convert_to_hash/map.rb

Instance Attribute Summary

Attributes inherited from Base

#data, #type

Instance Method Summary collapse

Methods inherited from Base

#initialize, #value

Constructor Details

This class inherits a constructor from TezosClient::Tools::ConvertToHash::Base

Instance Method Details

#decodeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tezos_client/tools/convert_to_hash/map.rb', line 7

def decode
  new_map = {}

  data.each do |elem|
    raise "Not a 'Map' type" unless elem[:prim] == "Elt"

    key = TezosClient::Tools::ConvertToHash::Base.new(
      data: elem[:args].first,
      type: type[:args].first
    ).value

    value = TezosClient::Tools::ConvertToHash::Base.new(
      data: elem[:args].second,
      type: type[:args].second
    ).value

    new_map[key] = value
  end

  new_map
end