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.
-
#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 |
# 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] 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 |
#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
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slack-notify/payload.rb', line 17 def to_hash hash = { text: text, username: username, channel: channel, icon_url: icon_url, icon_emoji: icon_emoji } hash.delete_if { |_,v| v.nil? } end |