Sha256: f220c012174a06301fa6faeb09bfe7972538699f7c9eb59acea2f42dc2b070a1

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Layout
      class RichText
        module RichTextElements
          # https://api.slack.com/reference/block-kit/blocks#element-types
          class Link
            include RichTextElements::StyleHelper
            TYPE = 'link'
            VALID_STYLES = %w[bold italic strike code].freeze

            def initialize(url:, text: nil, unsafe: nil, styles: [])
              @url = url
              @text = text
              @unsafe = unsafe
              @styles = styles
              validate_styles(styles, VALID_STYLES)
            end

            def as_json(*)
              {
                type: TYPE,
                url: @url,
                text: @text,
                unsafe: @unsafe,
                style: styles_as_json(@styles)
              }.compact
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb
slack-ruby-block-kit-0.24.0 lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb