Class: Yandex::Translate::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex-translate.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/yandex-translate.rb', line 6

def initialize(key)
  @connect = Yandex::Translate::Connect.new(key)
end

Instance Method Details

#detect(text) ⇒ Object



15
16
17
18
# File 'lib/yandex-translate.rb', line 15

def detect(text)
  data = {"text" => text}
  return @connect.get('detect', data)
end

#get_langs(lang = 'en') ⇒ Object



10
11
12
13
# File 'lib/yandex-translate.rb', line 10

def get_langs(lang = 'en')
  data = {"ui" => lang}
  return @connect.get('getLangs', data)
end

#translate(text, lang = 'ru', format = 'plain') ⇒ Object



20
21
22
23
# File 'lib/yandex-translate.rb', line 20

def translate(text, lang = 'ru', format = 'plain')
  data = {"text" => text, "lang" => lang, "format" => format}
  return @connect.get('translate', data)
end