Class: TonSdk::Abi::AbiParam

Inherits:
Object
  • Object
show all
Defined in:
lib/ton_sdk_client/abi.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type_:, components: []) ⇒ AbiParam

Returns a new instance of AbiParam.



437
438
439
440
441
# File 'lib/ton_sdk_client/abi.rb', line 437

def initialize(name:, type_:, components: [])
  @name = name
  @type_ = type_
  @components = components
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



435
436
437
# File 'lib/ton_sdk_client/abi.rb', line 435

def components
  @components
end

#nameObject (readonly)

Returns the value of attribute name.



435
436
437
# File 'lib/ton_sdk_client/abi.rb', line 435

def name
  @name
end

#type_Object (readonly)

Returns the value of attribute type_.



435
436
437
# File 'lib/ton_sdk_client/abi.rb', line 435

def type_
  @type_
end

Class Method Details

.from_json(j) ⇒ Object



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'lib/ton_sdk_client/abi.rb', line 455

def self.from_json(j)
  return nil if j.nil?

  comp_s = if j["components"].nil?
    []
  else
    j["components"].compact.map do |x|
      # TODO recursive parsing of AbiParam
      self.from_json(x)
    end
  end

  self.new(
    name: j["name"],
    type_: j["type"],
    components: comp_s
  )
end

Instance Method Details

#to_hObject



443
444
445
446
447
448
449
450
451
452
453
# File 'lib/ton_sdk_client/abi.rb', line 443

def to_h
  cm_h_s = if !@components.nil?
    @components.compact.map(&:to_h)
  end

  {
    name: @name,
    type: @type_,
    components: cm_h_s
  }
end