Class: Bas::Bot::Base
- Inherits:
-
Object
- Object
- Bas::Bot::Base
- Defined in:
- lib/bas/bot/base.rb
Overview
The Bot::Base class serves as the foundation for implementing specific bots. Operating as an interface, this class defines essential attributes and methods, providing a blueprint for creating custom bots formed by a Read, Process, and Write components.
Instance Attribute Summary collapse
-
#process_options ⇒ Object
readonly
Returns the value of attribute process_options.
-
#process_response ⇒ Object
Returns the value of attribute process_response.
-
#read_response ⇒ Object
Returns the value of attribute read_response.
-
#shared_storage_reader ⇒ Object
readonly
Returns the value of attribute shared_storage_reader.
-
#shared_storage_writer ⇒ Object
readonly
Returns the value of attribute shared_storage_writer.
-
#write_response ⇒ Object
Returns the value of attribute write_response.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options, shared_storage_reader, shared_storage_writer = nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(options, shared_storage_reader, shared_storage_writer = nil) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 |
# File 'lib/bas/bot/base.rb', line 17 def initialize(, shared_storage_reader, shared_storage_writer = nil) = { close_connections_after_process: true } @process_options = .merge( || {}) @shared_storage_reader = shared_storage_reader @shared_storage_writer = shared_storage_writer || shared_storage_reader end |
Instance Attribute Details
#process_options ⇒ Object (readonly)
Returns the value of attribute process_options.
14 15 16 |
# File 'lib/bas/bot/base.rb', line 14 def @process_options end |
#process_response ⇒ Object
Returns the value of attribute process_response.
15 16 17 |
# File 'lib/bas/bot/base.rb', line 15 def process_response @process_response end |
#read_response ⇒ Object
Returns the value of attribute read_response.
15 16 17 |
# File 'lib/bas/bot/base.rb', line 15 def read_response @read_response end |
#shared_storage_reader ⇒ Object (readonly)
Returns the value of attribute shared_storage_reader.
14 15 16 |
# File 'lib/bas/bot/base.rb', line 14 def shared_storage_reader @shared_storage_reader end |
#shared_storage_writer ⇒ Object (readonly)
Returns the value of attribute shared_storage_writer.
14 15 16 |
# File 'lib/bas/bot/base.rb', line 14 def shared_storage_writer @shared_storage_writer end |
#write_response ⇒ Object
Returns the value of attribute write_response.
15 16 17 |
# File 'lib/bas/bot/base.rb', line 15 def write_response @write_response end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bas/bot/base.rb', line 24 def execute @read_response = read @shared_storage_reader.set_in_process @process_response = process raise Utils::Exceptions::InvalidProcessResponse unless process_response.is_a?(Hash) @shared_storage_reader.set_processed @write_response = write close_connections if @process_options[:close_connections_after_process].eql?(true) @write_response end |