Class: Discordrb::Webhooks::View::ContainerBuilder
- Inherits:
-
Object
- Object
- Discordrb::Webhooks::View::ContainerBuilder
- Defined in:
- lib/discordrb/webhooks/view.rb
Overview
This builder can be used to construct a container. These are similar to embeds.
Instance Method Summary collapse
-
#colour=(colour) ⇒ Object
(also: #color=)
Set the color of the container.
-
#file ⇒ Object
(also: #file_display)
Add a file component to the container.
-
#initialize(id: nil, color: nil, colour: nil, spoiler: false) {|builder| ... } ⇒ ContainerBuilder
constructor
Create a container component.
-
#media_gallery ⇒ Object
Add a media gallery component to the container.
-
#row ⇒ Object
Add a row component to the container.
-
#section ⇒ Object
Add a section component to the container.
-
#separator ⇒ Object
Add a separator component to the container.
-
#text_display ⇒ Object
Add a text display component to the container.
Constructor Details
#initialize(id: nil, color: nil, colour: nil, spoiler: false) {|builder| ... } ⇒ ContainerBuilder
Create a container component.
351 352 353 354 355 356 357 358 |
# File 'lib/discordrb/webhooks/view.rb', line 351 def initialize(id: nil, color: nil, colour: nil, spoiler: false) @id = id @spoiler = spoiler @components = [] self.colour = (colour || color) yield self if block_given? end |
Instance Method Details
#colour=(colour) ⇒ Object Also known as: color=
Set the color of the container.
400 401 402 403 404 405 406 407 408 409 |
# File 'lib/discordrb/webhooks/view.rb', line 400 def colour=(colour) @colour = case colour when Array (colour[0] << 16) | (colour[1] << 8) | colour[2] when String colour.delete('#').to_i(16) else colour&.to_i end end |
#file ⇒ Object Also known as: file_display
Add a file component to the container.
368 369 370 |
# File 'lib/discordrb/webhooks/view.rb', line 368 def file(...) @components << FileBuilder.new(...) end |
#media_gallery ⇒ Object
Add a media gallery component to the container.
394 395 396 |
# File 'lib/discordrb/webhooks/view.rb', line 394 def media_gallery(...) @components << MediaGalleryBuilder.new(...) end |
#row ⇒ Object
Add a row component to the container.
362 363 364 |
# File 'lib/discordrb/webhooks/view.rb', line 362 def row(...) @components << RowBuilder.new(...) end |
#section ⇒ Object
Add a section component to the container.
376 377 378 |
# File 'lib/discordrb/webhooks/view.rb', line 376 def section(...) @components << SectionBuilder.new(...) end |
#separator ⇒ Object
Add a separator component to the container.
382 383 384 |
# File 'lib/discordrb/webhooks/view.rb', line 382 def separator(...) @components << SeparatorBuilder.new(...) end |
#text_display ⇒ Object
Add a text display component to the container.
388 389 390 |
# File 'lib/discordrb/webhooks/view.rb', line 388 def text_display(...) @components << TextDisplayBuilder.new(...) end |