Sha256: 4bab1d669cac03624aecb90dc05d776839ee6a5e40590f9fe16d8a949b4c79b8
Contents?: true
Size: 789 Bytes
Versions: 1
Compression:
Stored size: 789 Bytes
Contents
# frozen_string_literal: true module Slack module BlockKit module CompositionObjects class OptionGroup attr_reader :label, :options def self.[](hash) new.tap do |object| object.label = hash.fetch(:label) hash[:options].each(&object.options.method(:<<)) end end def initialize @options = TypeRestrictedArray.new(Option) end def label=(obj) raise TypeError, 'label must be a Text Object' unless obj.is_a?(Text) raise RangeError, 'label is max 75 characters' unless obj.text.size <= 75 @label = obj end def to_h { label: label.to_h, options: options.map(&:to_h) } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-block-kit-0.1.0 | lib/slack/block_kit/composition_objects/option_group.rb |