Class: Sterlet::RawClient

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ RawClient

Returns a new instance of RawClient.



3
4
5
# File 'lib/sterlet/raw_client.rb', line 3

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#detect(text, hints: []) ⇒ Object

rubocop:enable Naming/UncommunicativeMethodParamName



13
14
15
# File 'lib/sterlet/raw_client.rb', line 13

def detect(text, hints: [])
  perform_post_request('/detect', text: text, hints: hints)
end

#get_langs(ui: :en) ⇒ Object

rubocop:disable Naming/UncommunicativeMethodParamName



8
9
10
# File 'lib/sterlet/raw_client.rb', line 8

def get_langs(ui: :en)
  perform_post_request('/getLangs', ui: ui)
end

#translate(text, lang:, format: :plain, options: 0) ⇒ Object



17
18
19
20
# File 'lib/sterlet/raw_client.rb', line 17

def translate(text, lang:, format: :plain, options: 0)
  params = { text: text, lang: lang, format: format, options: options }
  perform_post_request('/translate', params)
end