Class: Yandex::Translate::Connect

Inherits:
Object
  • Object
show all
Defined in:
lib/connect.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Connect

Returns a new instance of Connect.



7
8
9
10
# File 'lib/connect.rb', line 7

def initialize(key)
  @key = key
  @rv = Yandex::Translate::ResponseVerify.new
end

Instance Method Details

#get(type, data) ⇒ Object



12
13
14
15
16
# File 'lib/connect.rb', line 12

def get(type, data)
  postfix = URI.encode_www_form(data)
  rep = JSON.parse(Net::HTTP.get(URI("#{BASE_URI}#{type}?key=#{@key}&#{postfix}")))
  return @rv.verify(rep)
end