class Slackbot

Constants

REMOTE_ENDPOINT
REMOTE_PATH

Public Class Methods

new(subdomain, token) click to toggle source
# File lib/slackbot.rb, line 10
def initialize(subdomain, token)
  @endpoint = URI(REMOTE_ENDPOINT % URI.encode(subdomain))
  @token = token
end

Public Instance Methods

send(channel, message) click to toggle source
# File lib/slackbot.rb, line 15
def send(channel, message)
  http = Net::HTTP.new(@endpoint.host, @endpoint.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(path(channel))
  request.body = message

  http.request(request)
end

Protected Instance Methods

path(channel) click to toggle source
# File lib/slackbot.rb, line 27
def path(channel)
  REMOTE_PATH % [@token, channel].map { |param| URI.encode(param) }
end