Class: Ellen::Adapters::Base
- Inherits:
-
Object
- Object
- Ellen::Adapters::Base
- Defined in:
- lib/ellen/adapters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Class Method Summary collapse
- .env(key, description, options = {}) ⇒ Object
- .envs ⇒ Object
- .inherited(child_class) ⇒ Object
- .usage ⇒ Object
Instance Method Summary collapse
-
#initialize(robot) ⇒ Base
constructor
A new instance of Base.
- #say(body, options = {}) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(robot) ⇒ Base
Returns a new instance of Base.
35 36 37 |
# File 'lib/ellen/adapters/base.rb', line 35 def initialize(robot) @robot = robot end |
Instance Attribute Details
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
33 34 35 |
# File 'lib/ellen/adapters/base.rb', line 33 def robot @robot end |
Class Method Details
.env(key, description, options = {}) ⇒ Object
20 21 22 |
# File 'lib/ellen/adapters/base.rb', line 20 def env(key, description, = {}) envs << Env.new(key, description, ) end |
.envs ⇒ Object
24 25 26 |
# File 'lib/ellen/adapters/base.rb', line 24 def envs @envs ||= [] end |
.inherited(child_class) ⇒ Object
16 17 18 |
# File 'lib/ellen/adapters/base.rb', line 16 def inherited(child_class) Ellen::AdapterBuilder.adapter_classes << child_class end |
.usage ⇒ Object
28 29 30 |
# File 'lib/ellen/adapters/base.rb', line 28 def usage envs.map(&:to_usage).join("\n") end |
Instance Method Details
#say(body, options = {}) ⇒ Object
39 40 41 |
# File 'lib/ellen/adapters/base.rb', line 39 def say(body, = {}) Ellen.logger.info("Not implemented #{self.class}##{__method__} was called") end |
#validate ⇒ Object
43 44 45 46 47 |
# File 'lib/ellen/adapters/base.rb', line 43 def validate self.class.envs.each(&:validate) rescue Env::MissingRequiredKeyError => exception Ellen.die("#{exception}\n#{self.class.usage}") end |