class SlackNotify::Client
Public Class Methods
new(options = {})
click to toggle source
# File lib/slack-notify/client.rb, line 8 def initialize(options = {}) @webhook_url = options[:webhook_url] @username = options[:username] @channel = options[:channel] @icon_url = options[:icon_url] @icon_emoji = options[:icon_emoji] @link_names = options[:link_names] @unfurl_links = options[:unfurl_links] || "1" if @webhook_url.nil? raise ArgumentError, "Webhook URL required" end end
Public Instance Methods
notify(text, channel = nil)
click to toggle source
# File lib/slack-notify/client.rb, line 26 def notify(text, channel = nil) delivery_channels(channel).each do |chan| payload = SlackNotify::Payload.new( text: text, channel: chan, username: @username, icon_url: @icon_url, icon_emoji: @icon_emoji, link_names: @link_names, unfurl_links: @unfurl_links ) send_payload(payload) end true end
test()
click to toggle source
# File lib/slack-notify/client.rb, line 22 def test notify("Test Message") end
Private Instance Methods
delivery_channels(channel)
click to toggle source
# File lib/slack-notify/client.rb, line 46 def delivery_channels(channel) [channel || @channel || "#general"].flatten.compact.uniq end