class Lita::Adapters::Slack::Attachment

A Slack attachment object. @api public @see api.slack.com/docs/attachments @since 1.6.0

Attributes

options[RW]
text[RW]

Public Class Methods

new(text, **options) click to toggle source

@param text [String] The main text of the message. @param options [Hash] Keyword arguments supporting all the option supported by Slack's

attachment API. These options will be passed to Slack as provided, with the exception
that the +:fallback+ option defaults to the value of +text+ (the first argument to this
method) and any value specified for the +:text+ option will be overwritten by the
explicit +text+ argument.
# File lib/lita/adapters/slack/attachment.rb, line 15
def initialize(text, **options)
  self.text = text
  self.options = options
end

Public Instance Methods

to_hash() click to toggle source

Converts the attachment into a hash, suitable for being sent to the Slack API. @return [Hash] The converted hash.

# File lib/lita/adapters/slack/attachment.rb, line 22
def to_hash
  options.merge({
    fallback: options[:fallback] || text,
    text: text,
  })
end