Class: SlackNotify::Client
- Inherits:
-
Object
- Object
- SlackNotify::Client
- Includes:
- Connection
- Defined in:
- lib/slack-notify/client.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #notify(text, channel = nil) ⇒ Object
- #test ⇒ Object
Methods included from Connection
#handle_response, #send_payload
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/slack-notify/client.rb', line 8 def initialize( = {}) @webhook_url = [:webhook_url] @username = [:username] @channel = [:channel] @icon_url = [:icon_url] @icon_emoji = [:icon_emoji] @link_names = [:link_names] @unfurl_links = [:unfurl_links] || "1" if @webhook_url.nil? raise ArgumentError, "Webhook URL required" end end |
Instance Method Details
#notify(text, channel = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/slack-notify/client.rb', line 22 def test notify("Test Message") end |