Class: Slackened::BlockKit::Blocks::Section
- Defined in:
- lib/slackened/block_kit/blocks/section.rb
Constant Summary collapse
- MAX_LENGTH =
10
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*fields) ⇒ Section
constructor
rubocop:disable Metrics/MethodLength.
Methods inherited from Base
Constructor Details
#initialize(*fields) ⇒ Section
rubocop:disable Metrics/MethodLength
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/slackened/block_kit/blocks/section.rb', line 12 def initialize(*fields) # rubocop:disable Metrics/MethodLength raise MaximumFieldsError, "#{fields.count} can't be greater than #{MAX_LENGTH}" if fields.length > MAX_LENGTH raise MustBeString unless fields.all? { |f| f.is_a? String } if fields.one? set({ type: :section, text: Text.new(fields.first) }) return self end set({ type: :section, fields: fields.map { |f| Text.new(f) } }) self end |