Class: Slack::BlockKit::Composition::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/composition/option.rb

Overview

Instance Method Summary collapse

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_jsonObject



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

Returns:

  • (Boolean)


19
20
21
# File 'lib/slack/block_kit/composition/option.rb', line 19

def initial?
  !!@initial
end