Class: SlackbotNotifier
- Inherits:
-
Object
- Object
- SlackbotNotifier
- Defined in:
- lib/slackbot_notifier.rb
Class Attribute Summary collapse
-
.slackbot_url ⇒ Object
Returns the value of attribute slackbot_url.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#room ⇒ Object
readonly
Returns the value of attribute room.
Instance Method Summary collapse
- #http ⇒ Object
-
#initialize(room = 'general') ⇒ SlackbotNotifier
constructor
A new instance of SlackbotNotifier.
- #notify(message) ⇒ Object
- #request ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(room = 'general') ⇒ SlackbotNotifier
Returns a new instance of SlackbotNotifier.
4 5 6 |
# File 'lib/slackbot_notifier.rb', line 4 def initialize(room = 'general') @room = SlackbotNotifier.production ? room : SlackbotNotifier.development_room end |
Class Attribute Details
.slackbot_url ⇒ Object
Returns the value of attribute slackbot_url.
28 29 30 |
# File 'lib/slackbot_notifier.rb', line 28 def slackbot_url @slackbot_url end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
2 3 4 |
# File 'lib/slackbot_notifier.rb', line 2 def end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
2 3 4 |
# File 'lib/slackbot_notifier.rb', line 2 def room @room end |
Instance Method Details
#http ⇒ Object
17 18 19 |
# File 'lib/slackbot_notifier.rb', line 17 def http @http ||= Net::HTTP.new(uri.host, uri.port).tap { |h| h.use_ssl = uri.scheme == 'https' } end |
#notify(message) ⇒ Object
8 9 10 11 |
# File 'lib/slackbot_notifier.rb', line 8 def notify() = http.request request end |
#request ⇒ Object
21 22 23 24 25 26 |
# File 'lib/slackbot_notifier.rb', line 21 def request @request ||= Net::HTTP::Post.new(uri.request_uri).tap do |r| r.body = r.content_type = 'text/xml' end end |
#uri ⇒ Object
13 14 15 |
# File 'lib/slackbot_notifier.rb', line 13 def uri @uri ||= URI "#{SlackbotNotifier.slackbot_url}&channel=%23#{room}" end |