class TezosClient::Tools::HashToMicheline::Base
Attributes
data[RW]
type[RW]
Public Class Methods
new(data:, type:)
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 7 def initialize(data:, type:) @data = data @type = type end
Public Instance Methods
value()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 14 def value @data = anonymous? ? @data : @data.fetch(var_name) encode end
Protected Instance Methods
anonymous?()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 31 def anonymous? !(type.key?(:annots) && type[:annots].any?) end
encode()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 20 def encode klass.new( data: data, type: type ).encode rescue NameError raise raise NotImplementedError, "type '#{type[:prim]}' not implemented" end
var_name()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 39 def var_name return nil if anonymous? "#{var_name_annot[1..-1]}".to_sym end
var_name_annot()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 35 def var_name_annot type[:annots].first end
Private Instance Methods
klass()
click to toggle source
# File lib/tezos_client/tools/hash_to_micheline/base.rb, line 46 def klass "#{self.class.name.deconstantize}::#{type[:prim].to_s.camelize}".constantize end