Class: Slackened::BlockKit::Blocks::Button

Inherits:
Base
  • Object
show all
Defined in:
lib/slackened/block_kit/blocks/button.rb

Constant Summary collapse

MAX_LENGTH =
75

Instance Attribute Summary

Attributes inherited from Base

#block

Instance Method Summary collapse

Methods inherited from Base

#set, #to_h

Constructor Details

#initialize(plain_text:, action_id:, value:) ⇒ Button

rubocop:disable Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/slackened/block_kit/blocks/button.rb', line 12

def initialize(plain_text:, action_id:, value:) # rubocop:disable Metrics/MethodLength
	raise MinimumCharactersError if plain_text.length.zero?
	raise MaximumCharactersError, "#{plain_text} can't be greater than #{MAX_LENGTH}" if plain_text.length > MAX_LENGTH

	set({
		action_id:,
		text: {
			type: :plain_text,
			text: plain_text
		},
		type: :button,
		value:
	})

	self
end