Class: ApiAiWrapper::Engine
Constant Summary collapse
- AUTOLOAD_CLASSES =
[ ApiAiWrapper::Trainers::EntityTrainer, ApiAiWrapper::Trainers::IntentTrainer, ApiAiWrapper::MeaningExtractor ]
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#client ⇒ Object
Returns the value of attribute client.
-
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
-
#client_token ⇒ Object
Returns the value of attribute client_token.
-
#developer_token ⇒ Object
Returns the value of attribute developer_token.
-
#entity_trainer ⇒ Object
Returns the value of attribute entity_trainer.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#intent_trainer ⇒ Object
Returns the value of attribute intent_trainer.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#meaning_extractor ⇒ Object
Returns the value of attribute meaning_extractor.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(options = {}) ⇒ Engine
Returns a new instance of Engine.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api_ai_wrapper/engine.rb', line 19 def initialize( = {}) self.client = HTTPClient.new self.client.receive_timeout = [:client_timeout].presence || ApiAiWrapper::Constants::DEFAULT_CLIENT_TIMEOUT self.locale = [:locale].presence || ApiAiWrapper::Constants::DEFAULT_LOCALE self.base_url = ApiAiWrapper::Constants::DEFAULT_BASE_URL self.version = [:version].presence || ApiAiWrapper::Constants::DEFAULT_VERSION self.client_token = [:client_token].presence self.developer_token = [:developer_token].presence # RAISE ERROR IF NO TOKEN PRESENT raise ApiAiWrapper::Errors::Engine::MissingTokens.new if self.client_token.blank? && self.developer_token.blank? # define entity_trainer and intent_trainer on the fly AUTOLOAD_CLASSES.each{ |class_name| instance = class_name.new instance.engine = self self.send("#{class_name.to_s.demodulize.underscore}=", instance) } end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def base_url @base_url end |
#client ⇒ Object
Returns the value of attribute client.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def client @client end |
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def client_timeout @client_timeout end |
#client_token ⇒ Object
Returns the value of attribute client_token.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def client_token @client_token end |
#developer_token ⇒ Object
Returns the value of attribute developer_token.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def developer_token @developer_token end |
#entity_trainer ⇒ Object
Returns the value of attribute entity_trainer.
17 18 19 |
# File 'lib/api_ai_wrapper/engine.rb', line 17 def entity_trainer @entity_trainer end |
#headers ⇒ Object
Returns the value of attribute headers.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def headers @headers end |
#intent_trainer ⇒ Object
Returns the value of attribute intent_trainer.
17 18 19 |
# File 'lib/api_ai_wrapper/engine.rb', line 17 def intent_trainer @intent_trainer end |
#locale ⇒ Object
Returns the value of attribute locale.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def locale @locale end |
#meaning_extractor ⇒ Object
Returns the value of attribute meaning_extractor.
17 18 19 |
# File 'lib/api_ai_wrapper/engine.rb', line 17 def meaning_extractor @meaning_extractor end |
#version ⇒ Object
Returns the value of attribute version.
16 17 18 |
# File 'lib/api_ai_wrapper/engine.rb', line 16 def version @version end |