class Slack::BlockKit::Layout::Context
Displays message context, which can include both images and text.
Constants
- TYPE
Attributes
elements[RW]
Public Class Methods
new(block_id: nil) { |self| ... }
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 13 def initialize(block_id: nil) @block_id = block_id @elements = [] yield(self) if block_given? end
Public Instance Methods
append(element)
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 32 def append(element) @elements << element self end
as_json(*)
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 38 def as_json(*) { type: TYPE, elements: @elements.map(&:as_json), block_id: @block_id }.compact end
image(url:, alt_text:)
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 20 def image(url:, alt_text:) append(Element::Image.new(image_url: url, alt_text: alt_text)) end
mrkdwn(text:, verbatim: nil)
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 28 def mrkdwn(text:, verbatim: nil) append(Composition::Mrkdwn.new(text: text, verbatim: verbatim)) end
plain_text(text:, emoji: nil)
click to toggle source
# File lib/slack/block_kit/layout/context.rb, line 24 def plain_text(text:, emoji: nil) append(Composition::PlainText.new(text: text, emoji: emoji)) end