Class: WatsonLanguage::ActiveMethod::Base
- Includes:
- Generators::LanguageRequest
- Defined in:
- lib/watson-language-translator/active_method/base.rb
Direct Known Subclasses
IdentifiableLanguages, Identify, ListModels, Model, ModelDetails, Translator
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#json_result ⇒ Object
Returns the value of attribute json_result.
-
#options ⇒ Object
Returns the value of attribute options.
-
#password ⇒ Object
Returns the value of attribute password.
-
#text ⇒ Object
Returns the value of attribute text.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #fetch_http_method ⇒ Object
-
#initialize(text = nil, options = {}) ⇒ Base
constructor
A new instance of Base.
- #params_addressable ⇒ Object
- #request ⇒ Object
Methods included from Generators::LanguageRequest
#base_url_request, #json_parser, #rest_client_api
Methods inherited from Extra
Constructor Details
#initialize(text = nil, options = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 |
# File 'lib/watson-language-translator/active_method/base.rb', line 7 def initialize(text = nil, ={}) @text = text @username = WatsonLanguage.username @password = WatsonLanguage.password @options = @http_method = fetch_http_method @json_result = request end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def http_method @http_method end |
#json_result ⇒ Object
Returns the value of attribute json_result.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def json_result @json_result end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def @options end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def password @password end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def text @text end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/watson-language-translator/active_method/base.rb', line 5 def username @username end |
Instance Method Details
#fetch_http_method ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/watson-language-translator/active_method/base.rb', line 26 def fetch_http_method if @options[:http_method] result = [:http_method] @options.delete(:http_method) else result = "get" end return result.to_sym end |
#params_addressable ⇒ Object
20 21 22 23 24 |
# File 'lib/watson-language-translator/active_method/base.rb', line 20 def params_addressable uri = Addressable::URI.new uri.query_values = @options uri.query end |
#request ⇒ Object
16 17 18 |
# File 'lib/watson-language-translator/active_method/base.rb', line 16 def request json_parser(endpoint) end |