class Slack::BlockKit::Layout::Section
A section is one of the most flexible blocks available - it can be used as a simple text block, in combination with text fields, or side-by-side with any of the available block elements.
Constants
- TYPE
Attributes
accessory[RW]
fields[RW]
text[RW]
Public Class Methods
new(block_id: nil) { |self| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 16 def initialize(block_id: nil) @block_id = block_id yield(self) if block_given? end
Public Instance Methods
accessorise(element)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 155 def accessorise(element) @accessory = element self end
as_json(*)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 161 def as_json(*) { type: TYPE, text: @text.as_json, block_id: @block_id, fields: @fields&.map(&:as_json), accessory: @accessory&.as_json }.compact end
channel_select(placeholder:, action_id:, initial: nil, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 65 def channel_select(placeholder:, action_id:, initial: nil, emoji: nil) element = Element::ChannelsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(element) if block_given? accessorise(element) end
conversation_select(placeholder:, action_id:, initial: nil, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 78 def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil) element = Element::ConversationsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(element) if block_given? accessorise(element) end
date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 91 def date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil) element = Element::DatePicker.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(element) if block_given? accessorise(element) end
external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 104 def external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) element = Element::ExternalSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, min_query_length: min_query_length, emoji: emoji ) yield(element) if block_given? accessorise(element) end
image(url:, alt_text:)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 151 def image(url:, alt_text:) accessorize(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/section.rb, line 44 def mrkdwn(text:, verbatim: nil) @text = Composition::Mrkdwn.new(text: text, verbatim: verbatim) self end
mrkdwn_field(text:, verbatim: nil)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 30 def mrkdwn_field(text:, verbatim: nil) @fields ||= [] @fields << Composition::Mrkdwn.new(text: text, verbatim: verbatim) self end
plain_text(text:, emoji: nil)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 38 def plain_text(text:, emoji: nil) @text = Composition::PlainText.new(text: text, emoji: emoji) self end
plaintext_field(text:, emoji: nil)
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 22 def plaintext_field(text:, emoji: nil) @fields ||= [] @fields << Composition::PlainText.new(text: text, emoji: emoji) self end
static_select(placeholder:, action_id:, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 126 def static_select(placeholder:, action_id:, emoji: nil) element = Element::StaticSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji ) yield(element) if block_given? accessorise(element) end
users_select(placeholder:, action_id:, initial: nil, emoji: nil) { |element| ... }
click to toggle source
# File lib/slack/block_kit/layout/section.rb, line 138 def users_select(placeholder:, action_id:, initial: nil, emoji: nil) element = Element::UsersSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji, initial: initial ) yield(element) if block_given? accessorise(element) end