Class: RandomAdapter
- Includes:
- Logging
- Defined in:
- lib/business/adapter/random_adapter.rb
Overview
Self implementation from Adapter class to make it works with a Random Phrase Generator
Constant Summary
Constants included from Logging
Instance Method Summary collapse
-
#connect_stream(stream = 1) ⇒ Object
Connects to a Random Phrase Generator and retrieves phrases.
-
#initialize ⇒ RandomAdapter
constructor
Initializes the Random Adapter class with the dao parameters.
-
#persist(status) ⇒ Object
Save the status in a database to release the execution charge of threat that info in real time.
Methods included from Logging
Constructor Details
#initialize ⇒ RandomAdapter
Initializes the Random Adapter class with the dao parameters
15 16 17 18 19 |
# File 'lib/business/adapter/random_adapter.rb', line 15 def initialize @dao = DAO.new 'rpg' end |
Instance Method Details
#connect_stream(stream = 1) ⇒ Object
Connects to a Random Phrase Generator and retrieves phrases
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/business/adapter/random_adapter.rb', line 25 def connect_stream (stream=1) logger.info('Starting Random adapter') random = RandomPhraseGenerator.new i=0 while true persist random.generate i = i+1 if i%10 == 0 sleep 10 end end end |
#persist(status) ⇒ Object
Save the status in a database to release the execution charge of threat that info in real time
46 47 48 |
# File 'lib/business/adapter/random_adapter.rb', line 46 def persist status @dao.save_status status end |