Class: Slack::BlockKit::Layout::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/layout/input.rb

Overview

A block that collects information from users - it can hold a plain-text input element, a select menu element, a multi-select menu element, or a datepicker.

api.slack.com/reference/block-kit/blocks#input

Constant Summary collapse

TYPE =
'input'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, element:, block_id: nil, hint: nil, optional: nil, emoji: nil) ⇒ Input

Returns a new instance of Input.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/slack/block_kit/layout/input.rb', line 16

def initialize(
  label:,
  element:,
  block_id: nil,
  hint: nil,
  optional: nil,
  emoji: nil
)
  @label = Composition::PlainText.new(text: label, emoji: emoji) if label
  @hint = Composition::PlainText.new(text: hint, emoji: emoji) if hint
  @block_id = block_id
  @optional = optional
  @element = element
end

Instance Attribute Details

#block_idObject

Returns the value of attribute block_id.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def block_id
  @block_id
end

#elementObject

Returns the value of attribute element.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def element
  @element
end

#emojiObject

Returns the value of attribute emoji.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def emoji
  @emoji
end

#hintObject

Returns the value of attribute hint.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def hint
  @hint
end

#labelObject

Returns the value of attribute label.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def label
  @label
end

#optionalObject

Returns the value of attribute optional.



14
15
16
# File 'lib/slack/block_kit/layout/input.rb', line 14

def optional
  @optional
end

Instance Method Details

#as_jsonObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/slack/block_kit/layout/input.rb', line 31

def as_json(*)
  {
    type: TYPE,
    element: @element.as_json,
    label: @label&.as_json,
    hint: @hint&.as_json,
    block_id: @block_id,
    optional: optional
  }.compact
end