Sha256: 9796678cc2b865eda8cbe23e05e28a670663d484c1b97a4142d05102f7b03013

Contents?: true

Size: 825 Bytes

Versions: 18

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Slack
  module BlockKit
    module Layout
      # A simple image block, designed to make those cat photos really pop.
      #
      # https://api.slack.com/reference/messaging/blocks#context
      class Image
        TYPE = 'image'

        def initialize(url:, alt_text:, title: nil, block_id: nil, emoji: nil)
          @image_url = url
          @alt_text = alt_text
          @block_id = block_id
          @title = title && Composition::PlainText.new(
            text: title,
            emoji: emoji
          )
        end

        def as_json(*)
          {
            type: TYPE,
            image_url: @image_url,
            alt_text: @alt_text,
            title: @title&.as_json,
            block_id: @block_id
          }.compact
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.24.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.23.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.22.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.21.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.20.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.19.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.18.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.17.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.16.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.15.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.14.1 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.14.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.13.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.12.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.11.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.10.0 lib/slack/block_kit/layout/image.rb
slack-ruby-block-kit-0.9.0 lib/slack/block_kit/layout/image.rb