Class: EverSdk::Abi::AbiParam

Inherits:
Object
  • Object
show all
Defined in:
lib/ever_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.



457
458
459
460
461
# File 'lib/ever_sdk_client/abi.rb', line 457

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

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



455
456
457
# File 'lib/ever_sdk_client/abi.rb', line 455

def components
  @components
end

#nameObject (readonly)

Returns the value of attribute name.



455
456
457
# File 'lib/ever_sdk_client/abi.rb', line 455

def name
  @name
end

#type_Object (readonly)

Returns the value of attribute type_.



455
456
457
# File 'lib/ever_sdk_client/abi.rb', line 455

def type_
  @type_
end

Class Method Details

.from_json(j) ⇒ Object



475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/ever_sdk_client/abi.rb', line 475

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



463
464
465
466
467
468
469
470
471
472
473
# File 'lib/ever_sdk_client/abi.rb', line 463

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

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