Class: Slackened::BlockKit::Blocks::Context
- Defined in:
- lib/slackened/block_kit/blocks/context.rb
Constant Summary collapse
- MAX_LENGTH =
10
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*elements) ⇒ Context
constructor
A new instance of Context.
Methods inherited from Base
Constructor Details
#initialize(*elements) ⇒ Context
Returns a new instance of Context.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slackened/block_kit/blocks/context.rb', line 12 def initialize(*elements) raise MaximumElementsError, "#{elements.count} can't be greater than #{MAX_LENGTH}" if elements.length > MAX_LENGTH # TODO: need to allow for image # https://api.slack.com/reference/block-kit/blocks#context set({ type: :context, elements: elements.map do |element| raise MustBeString, "#{element} must be a string" unless element.is_a? String Text.new(element) end }) self end |