Class: Ellen::Adapters::Base
- Inherits:
-
Object
- Object
- Ellen::Adapters::Base
- Defined in:
- lib/ellen/adapters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Class Method Summary collapse
- .env(key, description, options = {}) ⇒ Object
- .envs ⇒ Object
- .inherited(child) ⇒ Object
- .usage ⇒ Object
Instance Method Summary collapse
-
#initialize(robot, options) ⇒ Base
constructor
A new instance of Base.
- #say(body, options = {}) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(robot, options) ⇒ Base
Returns a new instance of Base.
35 36 37 38 |
# File 'lib/ellen/adapters/base.rb', line 35 def initialize(robot, ) @robot = robot @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
33 34 35 |
# File 'lib/ellen/adapters/base.rb', line 33 def @options end |
#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) ⇒ Object
16 17 18 |
# File 'lib/ellen/adapters/base.rb', line 16 def inherited(child) Ellen.adapters[child.name.split("::").last.underscore] = child 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
40 41 42 |
# File 'lib/ellen/adapters/base.rb', line 40 def say(body, = {}) Ellen.logger.info("Not implemented #{self.class}##{__method__} was called") end |
#validate ⇒ Object
44 45 46 47 48 |
# File 'lib/ellen/adapters/base.rb', line 44 def validate self.class.envs.each(&:validate) rescue Env::MissingRequiredKeyError => exception Ellen.die("#{exception}\n#{self.class.usage}") end |