Class: SlackNotify::Payload
- Inherits:
-
Object
- Object
- SlackNotify::Payload
- Defined in:
- lib/slack-notify/payload.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#icon_emoji ⇒ Object
Returns the value of attribute icon_emoji.
-
#icon_url ⇒ Object
Returns the value of attribute icon_url.
-
#link_names ⇒ Object
Returns the value of attribute link_names.
-
#text ⇒ Object
Returns the value of attribute text.
-
#unfurl_links ⇒ Object
Returns the value of attribute unfurl_links.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Payload
constructor
A new instance of Payload.
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Payload
Returns a new instance of Payload.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/slack-notify/payload.rb', line 11 def initialize( = {}) @username = [:username] || "webhookbot" @channel = [:channel] || "#general" @text = [:text] @icon_url = [:icon_url] @icon_emoji = [:icon_emoji] @link_names = [:link_names] @unfurl_links = [:unfurl_links] || "1" unless channel[0] =~ /^(#|@)/ @channel = "##{@channel}" end end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def channel @channel end |
#icon_emoji ⇒ Object
Returns the value of attribute icon_emoji.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def icon_emoji @icon_emoji end |
#icon_url ⇒ Object
Returns the value of attribute icon_url.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def icon_url @icon_url end |
#link_names ⇒ Object
Returns the value of attribute link_names.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def link_names @link_names end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def text @text end |
#unfurl_links ⇒ Object
Returns the value of attribute unfurl_links.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def unfurl_links @unfurl_links end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/slack-notify/payload.rb', line 3 def username @username end |
Instance Method Details
#to_hash ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/slack-notify/payload.rb', line 25 def to_hash hash = { text: text, username: username, channel: channel, icon_url: icon_url, icon_emoji: icon_emoji, link_names: link_names, unfurl_links: unfurl_links } hash.delete_if { |_,v| v.nil? } end |