Class: FDE::Slack::Message
- Inherits:
-
Object
- Object
- FDE::Slack::Message
- Defined in:
- lib/slack/message.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- BLUE =
'#BDE5F8'.freeze
- GREEN =
'#DFF2BF'.freeze
- YELLOW =
'#FEEFB3'.freeze
- RED =
'#FFBABA'.freeze
- RETRY_LIMIT =
1- TOO_MANY_REQUESTS_STATUS_CODE =
"429"
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#color ⇒ Object
Returns the value of attribute color.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#footer ⇒ Object
Returns the value of attribute footer.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#title ⇒ Object
Returns the value of attribute title.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #add_field(field) ⇒ Object
- #deliver(channel, level: :info) ⇒ Object
- #error(channel) ⇒ Object
- #info(channel) ⇒ Object
-
#initialize(title, fields, options = {}) ⇒ Message
constructor
A new instance of Message.
- #success(channel) ⇒ Object
- #warning(channel) ⇒ Object
Constructor Details
#initialize(title, fields, options = {}) ⇒ Message
Returns a new instance of Message.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/slack/message.rb', line 25 def initialize(title, fields, = {}) @title = title @fields = fields if [:title_link] @title_link = [:title_link] end if [:username] @username = [:username] || 'FDE Slack Notifier' end if [:author] = [:author] end if [:footer] = [:footer] end @retries = 0 end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def end |
#color ⇒ Object
Returns the value of attribute color.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def color @color end |
#fields ⇒ Object
Returns the value of attribute fields.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def fields @fields end |
#footer ⇒ Object
Returns the value of attribute footer.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
23 24 25 |
# File 'lib/slack/message.rb', line 23 def retries @retries end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def title @title end |
#username ⇒ Object
Returns the value of attribute username.
16 17 18 |
# File 'lib/slack/message.rb', line 16 def username @username end |
Instance Method Details
#add_field(field) ⇒ Object
68 69 70 |
# File 'lib/slack/message.rb', line 68 def add_field(field) @fields << field.to_h end |
#deliver(channel, level: :info) ⇒ Object
44 45 46 |
# File 'lib/slack/message.rb', line 44 def deliver(channel, level: :info) send(level, channel) end |
#error(channel) ⇒ Object
63 64 65 66 |
# File 'lib/slack/message.rb', line 63 def error(channel) @color = RED (channel) end |
#info(channel) ⇒ Object
48 49 50 51 |
# File 'lib/slack/message.rb', line 48 def info(channel) @color = BLUE (channel) end |
#success(channel) ⇒ Object
53 54 55 56 |
# File 'lib/slack/message.rb', line 53 def success(channel) @color = GREEN (channel) end |
#warning(channel) ⇒ Object
58 59 60 61 |
# File 'lib/slack/message.rb', line 58 def warning(channel) @color = YELLOW (channel) end |