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.
-
#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.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/slack-notify/payload.rb', line 5 def initialize( = {}) @username = [:username] || "webhookbot" @channel = [:channel] || "#general" @text = [:text] @icon_url = [:icon_url] @icon_emoji = [:icon_emoji] @link_names = [:link_names] 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 |
#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
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/slack-notify/payload.rb', line 18 def to_hash hash = { text: text, username: username, channel: channel, icon_url: icon_url, icon_emoji: icon_emoji, link_names: link_names } hash.delete_if { |_,v| v.nil? } end |