Class: Slack::BlockKit::Composition::OptionGroup
- Inherits:
-
Object
- Object
- Slack::BlockKit::Composition::OptionGroup
- Defined in:
- lib/slack/block_kit/composition/option_group.rb
Overview
Provides a way to group options in a select menu.
api.slack.com/reference/messaging/composition-objects#option-group api.slack.com/reference/messaging/block-elements#select
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(label:, emoji: nil) {|_self| ... } ⇒ OptionGroup
constructor
A new instance of OptionGroup.
- #option(text:, value:, emoji: nil, initial: false) ⇒ Object
Constructor Details
#initialize(label:, emoji: nil) {|_self| ... } ⇒ OptionGroup
Returns a new instance of OptionGroup.
13 14 15 16 17 18 |
# File 'lib/slack/block_kit/composition/option_group.rb', line 13 def initialize(label:, emoji: nil) @label = PlainText.new(text: label, emoji: emoji) @options = [] yield(self) if block_given? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/slack/block_kit/composition/option_group.rb', line 11 def @options end |
Instance Method Details
#as_json ⇒ Object
26 27 28 29 30 31 |
# File 'lib/slack/block_kit/composition/option_group.rb', line 26 def as_json(*) { label: @label.as_json, options: @options.map(&:as_json) } end |