Class: Slack::BlockKit::Element::RadioButtons
- Inherits:
-
Object
- Object
- Slack::BlockKit::Element::RadioButtons
- Defined in:
- lib/slack/block_kit/element/radio_buttons.rb
Overview
A radio button group that allows a user to choose one item from a list of possible options.
Constant Summary collapse
- TYPE =
'radio_buttons'
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(action_id:, focus_on_load: nil) {|_self| ... } ⇒ RadioButtons
constructor
A new instance of RadioButtons.
- #option(value:, text:, initial: false, emoji: nil) ⇒ Object
Methods included from Composition::ConfirmationDialog::Confirmable
#confirmation_dialog, included
Constructor Details
#initialize(action_id:, focus_on_load: nil) {|_self| ... } ⇒ RadioButtons
Returns a new instance of RadioButtons.
16 17 18 19 20 21 22 |
# File 'lib/slack/block_kit/element/radio_buttons.rb', line 16 def initialize(action_id:, focus_on_load: nil) @action_id = action_id @focus_on_load = focus_on_load @options = [] yield(self) if block_given? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/slack/block_kit/element/radio_buttons.rb', line 14 def @options end |
Instance Method Details
#as_json ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/slack/block_kit/element/radio_buttons.rb', line 37 def as_json(*) { type: TYPE, action_id: @action_id, focus_on_load: @focus_on_load, options: @options.map(&:as_json), initial_option: initial_option&.as_json, confirm: confirm&.as_json }.compact end |
#option(value:, text:, initial: false, emoji: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/slack/block_kit/element/radio_buttons.rb', line 24 def option(value:, text:, initial: false, emoji: nil) option = Composition::Option.new( value: value, text: text, initial: initial, emoji: emoji ) @options << option self end |