Class: YandexTranslator::Connection

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Celluloid::Notifications
Defined in:
lib/yat/connection.rb

Instance Method Summary collapse

Constructor Details

#initializeConnection

def finalize

p "connection dead!"

end



16
17
18
19
20
# File 'lib/yat/connection.rb', line 16

def initialize
  uri = URI(YandexTranslator::configuration.host)
  @session = Net::HTTP.start(uri.host, uri.port,
    :use_ssl => uri.scheme == 'https')
end

Instance Method Details

#request(uri, request_index, params = nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/yat/connection.rb', line 22

def request(uri, request_index, params = nil)
  response = @session.request(Net::HTTP::Post.new(uri),
    req = URI.encode_www_form(params || {}))

  publish(:connection_response, request_index, response)
end