Sha256: cfa6478d3ec70b0a7b31db0eb873bf506650e896bafcd095181a4eda85969114

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

module Slack
  class Payload
    attr_accessor :username, :channel, :text, :token

    def initialize(options = {})
      @username   = options[:username] || Slack.default_username
      @channel    = options[:channel] || Slack.default_channel
      @text       = options[:text]
      @token      = options[:token]

      unless channel[0] =~ /^(#|@)/
        @channel = "##{@channel}"
      end
    end

    def to_hash
     hash = {
        text:       text,
        username:   username,
        channel:    channel,
        token:      token
      }

      hash.delete_if { |_,v| v.nil? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack.rb-0.0.5 lib/slack/payload.rb