Class: DiscordRDA::Components::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/discord_rda/interactions/components.rb

Overview

Base component class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, data = {}) ⇒ Base

Returns a new instance of Base.



47
48
49
50
# File 'lib/discord_rda/interactions/components.rb', line 47

def initialize(type, data = {})
  @type = type
  @data = { type: TYPES[type] || type }.merge(data)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



45
46
47
# File 'lib/discord_rda/interactions/components.rb', line 45

def data
  @data
end

#typeObject (readonly)

Returns the value of attribute type.



45
46
47
# File 'lib/discord_rda/interactions/components.rb', line 45

def type
  @type
end

Instance Method Details

#to_hHash

Convert to hash for API

Returns:

  • (Hash)

    Component hash



54
55
56
# File 'lib/discord_rda/interactions/components.rb', line 54

def to_h
  @data
end