Class: TonSdk::Abi::AbiData

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(key:, name:, type_:, components: []) ⇒ AbiData

Returns a new instance of AbiData.



521
522
523
524
525
526
# File 'lib/ton_sdk_client/abi.rb', line 521

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

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



519
520
521
# File 'lib/ton_sdk_client/abi.rb', line 519

def components
  @components
end

#keyObject (readonly)

Returns the value of attribute key.



519
520
521
# File 'lib/ton_sdk_client/abi.rb', line 519

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



519
520
521
# File 'lib/ton_sdk_client/abi.rb', line 519

def name
  @name
end

#type_Object (readonly)

Returns the value of attribute type_.



519
520
521
# File 'lib/ton_sdk_client/abi.rb', line 519

def type_
  @type_
end

Class Method Details

.from_json(j) ⇒ Object



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/ton_sdk_client/abi.rb', line 541

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
      AbiParam.from_json(x)
    end
  end

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

Instance Method Details

#to_hObject



528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/ton_sdk_client/abi.rb', line 528

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

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