Class: Yandex::Client
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
- #complete(q, lang) ⇒ Object
-
#initialize(access_token) ⇒ Client
constructor
A new instance of Client.
- #langs ⇒ Object (also: #get_langs)
- #visit(address, options = {}) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Client
Returns a new instance of Client.
10 11 12 |
# File 'lib/yandex/client.rb', line 10 def initialize(access_token) @access_token = access_token || ENV['PREDICTOR_ACCESS_TOKEN'] end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/yandex/client.rb', line 6 def access_token @access_token end |
Instance Method Details
#complete(q, lang) ⇒ Object
19 20 21 22 |
# File 'lib/yandex/client.rb', line 19 def complete(q, lang) = { q: q, lang: lang } visit('/complete', ).parsed_response end |
#langs ⇒ Object Also known as: get_langs
14 15 16 |
# File 'lib/yandex/client.rb', line 14 def langs @langs ||= visit('/getLangs').parsed_response end |
#visit(address, options = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/yandex/client.rb', line 24 def visit(address, = {}) response = self.class.post address, body: .merge(key: access_token) check_errors(response) response end |