Class: Discorb::Embed::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/discorb/embed.rb

Overview

Represents a field of embed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, inline: true) -> Field

Initialize a new Field object.

Parameters:

  • name (String)

    The name of field.

  • value (String)

    The value of field.

  • inline (Boolean) (defaults to: true)

    Whether the field is inline.



202
203
204
205
206
# File 'lib/discorb/embed.rb', line 202

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

Instance Attribute Details

#inline -> Boolean

Returns Whether the field is inline.

Returns:

  • (Boolean)

    Whether the field is inline.



193
194
195
# File 'lib/discorb/embed.rb', line 193

def inline
  @inline
end

#name -> String

Returns The name of field.

Returns:

  • (String)

    The name of field.



189
190
191
# File 'lib/discorb/embed.rb', line 189

def name
  @name
end

#value -> String

Returns The value of field.

Returns:

  • (String)

    The value of field.



191
192
193
# File 'lib/discorb/embed.rb', line 191

def value
  @value
end

Instance Method Details

#to_hash -> Hash

Convert field to hash.

Returns:

  • (Hash)

    Converted field.

See Also:



214
215
216
217
218
219
220
# File 'lib/discorb/embed.rb', line 214

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