Class: Slackened::BlockKit::Blocks::Header

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

Constant Summary collapse

MAX_LENGTH =
150

Instance Attribute Summary

Attributes inherited from Base

#block

Instance Method Summary collapse

Methods inherited from Base

#set, #to_h

Constructor Details

#initialize(plain_text) ⇒ Header

Returns a new instance of Header.



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

def initialize(plain_text)
	raise MaximumCharactersError, "#{plain_text} can't be greater than #{MAX_LENGTH}" if plain_text.length > MAX_LENGTH
	raise MustBeString unless plain_text.is_a? String

	set({
		type: :header,
		text: {
			type: :plain_text, # cannot be :mrkdwn
			text: plain_text
		}
	})

	self
end