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.
379 380 381 382 383 384 385 386 |
# File 'lib/discordrb/webhooks/view.rb', line 379 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.
428 429 430 431 432 433 434 435 436 437 |
# File 'lib/discordrb/webhooks/view.rb', line 428 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.
396 397 398 |
# File 'lib/discordrb/webhooks/view.rb', line 396 def file(...) @components << FileBuilder.new(...) end |
#media_gallery ⇒ Object
Add a media gallery component to the container.
422 423 424 |
# File 'lib/discordrb/webhooks/view.rb', line 422 def media_gallery(...) @components << MediaGalleryBuilder.new(...) end |
#row ⇒ Object
Add a row component to the container.
390 391 392 |
# File 'lib/discordrb/webhooks/view.rb', line 390 def row(...) @components << RowBuilder.new(...) end |
#section ⇒ Object
Add a section component to the container.
404 405 406 |
# File 'lib/discordrb/webhooks/view.rb', line 404 def section(...) @components << SectionBuilder.new(...) end |
#separator ⇒ Object
Add a separator component to the container.
410 411 412 |
# File 'lib/discordrb/webhooks/view.rb', line 410 def separator(...) @components << SeparatorBuilder.new(...) end |
#text_display ⇒ Object
Add a text display component to the container.
416 417 418 |
# File 'lib/discordrb/webhooks/view.rb', line 416 def text_display(...) @components << TextDisplayBuilder.new(...) end |