Class: TezosClient::Tools::HashToMicheline::Pair

Inherits:
Base
  • Object
show all
Defined in:
lib/tezos_client/tools/hash_to_micheline/pair.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::HashToMicheline::Base

Instance Method Details

#data_0Object



23
24
25
26
27
28
29
# File 'lib/tezos_client/tools/hash_to_micheline/pair.rb', line 23

def data_0
  if data.is_a? ::Array
    data[0]
  else
    data
  end
end

#data_1Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tezos_client/tools/hash_to_micheline/pair.rb', line 31

def data_1
  if data.is_a? ::Array
    if data.size > 2
      data.drop(1)
    else
      data[1]
    end
  else
    data
  end
end

#encodeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tezos_client/tools/hash_to_micheline/pair.rb', line 7

def encode
  {
    prim: "Pair",
    args: [
      TezosClient::Tools::HashToMicheline::Base.new(
        data: data_0,
        type: type[:args][0]
      ).value,
      TezosClient::Tools::HashToMicheline::Base.new(
        data: data_1,
        type: type[:args][1]
      ).value
    ]
  }
end