Class: Nico::Responder

Inherits:
Object
  • Object
show all
Defined in:
lib/nico/room/responder.rb

Instance Method Summary collapse

Constructor Details

#initialize(subdomain, id, token) ⇒ Responder

Returns a new instance of Responder.



5
6
7
8
9
10
11
# File 'lib/nico/room/responder.rb', line 5

def initialize(subdomain, id, token)
  @http = Net::HTTP.new "#{subdomain}.campfirenow.com", 443
  @http.use_ssl = true
  @request = Net::HTTP::Post.new "/room/#{id}/speak.json"
  @request.basic_auth token, 'x'
  @request['Content-Type'] = 'application/json'
end

Instance Method Details

#push(response) ⇒ Object



13
14
15
16
# File 'lib/nico/room/responder.rb', line 13

def push(response)
  @request.body = {message: {body: response}}.to_json
  @http.request @request
end