Class: Slack::BlockKit::Composition::Option
- Inherits:
-
Object
- Object
- Slack::BlockKit::Composition::Option
- Defined in:
- lib/slack/block_kit/composition/option.rb
Overview
An object that represents a single selectable item in a select menu.
api.slack.com/reference/messaging/composition-objects#option api.slack.com/reference/messaging/block-elements#select
Instance Method Summary collapse
- #as_json ⇒ Object
- #initial? ⇒ Boolean
-
#initialize(value:, text:, initial: false, emoji: nil, description: nil, url: nil) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(value:, text:, initial: false, emoji: nil, description: nil, url: nil) ⇒ Option
Returns a new instance of Option.
11 12 13 14 15 16 17 |
# File 'lib/slack/block_kit/composition/option.rb', line 11 def initialize(value:, text:, initial: false, emoji: nil, description: nil, url: nil) @text = PlainText.new(text: text, emoji: emoji) @value = value @description = description && PlainText.new(text: description, emoji: emoji) @url = url @initial = initial end |
Instance Method Details
#as_json ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/slack/block_kit/composition/option.rb', line 23 def as_json(*) { text: @text.as_json, value: @value, description: @description&.as_json, url: @url }.compact end |
#initial? ⇒ Boolean
19 20 21 |
# File 'lib/slack/block_kit/composition/option.rb', line 19 def initial? !!@initial end |