Class: EverSdk::Abi::AbiData

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

Returns a new instance of AbiData.



541
542
543
544
545
546
# File 'lib/ever_sdk_client/abi.rb', line 541

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.



539
540
541
# File 'lib/ever_sdk_client/abi.rb', line 539

def components
  @components
end

#keyObject (readonly)

Returns the value of attribute key.



539
540
541
# File 'lib/ever_sdk_client/abi.rb', line 539

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



539
540
541
# File 'lib/ever_sdk_client/abi.rb', line 539

def name
  @name
end

#type_Object (readonly)

Returns the value of attribute type_.



539
540
541
# File 'lib/ever_sdk_client/abi.rb', line 539

def type_
  @type_
end

Class Method Details

.from_json(j) ⇒ Object



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/ever_sdk_client/abi.rb', line 561

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



548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/ever_sdk_client/abi.rb', line 548

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