Class: Pepito::Adapter
- Inherits:
-
Object
- Object
- Pepito::Adapter
- Defined in:
- lib/pepito/adapter.rb
Overview
Parent class for any adapter Adapters allow to communicate with the bot from differente platforms.
Constant Summary collapse
- REQUIRED_METHODS =
List of required methods for adapters
%i( run send_messages topic stop ).freeze
Instance Attribute Summary collapse
-
#config ⇒ Hash<String,String>
readonly
Config hash for the adapter.
-
#robot ⇒ Pepito::Robot
readonly
The currently running robot.
Class Method Summary collapse
-
.configs ⇒ Array<Hash>
Configs for the adapter, override this method in the adapter.
Instance Method Summary collapse
-
#initialize(robot, config) ⇒ void
constructor
Initializes the Adapter class.
-
#run ⇒ void
abstract
Runs the adapter.
-
#send_messages ⇒ void
abstract
Sends a message to the service.
-
#stop ⇒ void
abstract
Stops the adapter.
-
#topic ⇒ void
abstract
Sets the topic of the channel.
Constructor Details
#initialize(robot, config) ⇒ void
Initializes the Adapter class
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/pepito/adapter.rb', line 59 def initialize(robot, config) @robot = robot @config = config begin missing_methods missing_configuration_values rescue => e raise e end end |
Instance Attribute Details
#config ⇒ Hash<String,String> (readonly)
Config hash for the adapter
53 54 55 |
# File 'lib/pepito/adapter.rb', line 53 def config @config end |
#robot ⇒ Pepito::Robot (readonly)
The currently running robot
49 50 51 |
# File 'lib/pepito/adapter.rb', line 49 def robot @robot end |
Class Method Details
.configs ⇒ Array<Hash>
Configs for the adapter, override this method in the adapter
11 12 13 |
# File 'lib/pepito/adapter.rb', line 11 def configs [{}] end |
Instance Method Details
#run ⇒ void
This should be implemented by the adapter
This method returns an undefined value.
Runs the adapter
|
# File 'lib/pepito/adapter.rb', line 24
|
#send_messages ⇒ void
This should be implemented by the adapter
This method returns an undefined value.
Sends a message to the service
|
# File 'lib/pepito/adapter.rb', line 29
|
#stop ⇒ void
This should be implemented by the adapter
This method returns an undefined value.
Stops the adapter
|
# File 'lib/pepito/adapter.rb', line 42
|
#topic ⇒ void
This should be implemented by the adapter
This method returns an undefined value.
Sets the topic of the channel
|
# File 'lib/pepito/adapter.rb', line 36
|