Class: Discordrb::Webhooks::EmbedField

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/webhooks/embeds.rb

Overview

A field is a small block of text with a header that can be relatively freely layouted with other fields.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, value: nil, inline: false) ⇒ EmbedField

Creates a new field object.

Parameters:

  • name (String, nil) (defaults to: nil)

    The name of the field, displayed in bold at the top of the field.

  • value (String, nil) (defaults to: nil)

    The value of the field, displayed in normal text below the name.

  • inline (true, false) (defaults to: false)

    Whether the field should be displayed inline with other fields.


227
228
229
230
231
# File 'lib/discordrb/webhooks/embeds.rb', line 227

def initialize(name: nil, value: nil, inline: false)
  @name = name
  @value = value
  @inline = inline
end

Instance Attribute Details

#inlinetrue, false

Returns whether the field should be displayed inline with other fields.

Returns:

  • (true, false)

    whether the field should be displayed inline with other fields.


221
222
223
# File 'lib/discordrb/webhooks/embeds.rb', line 221

def inline
  @inline
end

#nameString?

Returns name of the field, displayed in bold at the top of the field.

Returns:

  • (String, nil)

    name of the field, displayed in bold at the top of the field.


215
216
217
# File 'lib/discordrb/webhooks/embeds.rb', line 215

def name
  @name
end

#valueString?

Returns value of the field, displayed in normal text below the name.

Returns:

  • (String, nil)

    value of the field, displayed in normal text below the name.


218
219
220
# File 'lib/discordrb/webhooks/embeds.rb', line 218

def value
  @value
end

Instance Method Details

#to_hashHash

Returns a hash representation of this embed field, to be converted to JSON.

Returns:

  • (Hash)

    a hash representation of this embed field, to be converted to JSON.


234
235
236
237
238
239
240
# File 'lib/discordrb/webhooks/embeds.rb', line 234

def to_hash
  {
    name: @name,
    value: @value,
    inline: @inline
  }
end