Class: Slack::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-notifier.rb,
lib/slack-notifier/version.rb,
lib/slack-notifier/http_post.rb,
lib/slack-notifier/link_formatter.rb

Defined Under Namespace

Classes: HTTPPost, LinkFormatter

Constant Summary collapse

VERSION =
"0.3.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team, token, hook_name = default_hook_name) ⇒ Notifier

Returns a new instance of Notifier.



17
18
19
20
21
# File 'lib/slack-notifier.rb', line 17

def initialize team, token, hook_name = default_hook_name
  @team  = team
  @token = token
  @hook_name = hook_name
end

Instance Attribute Details

#channelObject

these act as defaults if they are set



13
14
15
# File 'lib/slack-notifier.rb', line 13

def channel
  @channel
end

#hook_nameObject (readonly)

Returns the value of attribute hook_name.



15
16
17
# File 'lib/slack-notifier.rb', line 15

def hook_name
  @hook_name
end

#teamObject (readonly)

Returns the value of attribute team.



15
16
17
# File 'lib/slack-notifier.rb', line 15

def team
  @team
end

#tokenObject (readonly)

Returns the value of attribute token.



15
16
17
# File 'lib/slack-notifier.rb', line 15

def token
  @token
end

#usernameObject

these act as defaults if they are set



13
14
15
# File 'lib/slack-notifier.rb', line 13

def username
  @username
end

Instance Method Details

#ping(message, options = {}) ⇒ Object



23
24
25
26
27
28
# File 'lib/slack-notifier.rb', line 23

def ping message, options={}
  message = LinkFormatter.format(message)
  payload = { text: message }.merge(default_payload).merge(options)

  HTTPPost.to endpoint, payload: payload.to_json
end