Class: Ellen::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ellen/adapters/base.rb

Direct Known Subclasses

Shell

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, options)
  @robot = robot
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



33
34
35
# File 'lib/ellen/adapters/base.rb', line 33

def options
  @options
end

#robotObject (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, options = {})
  envs << Env.new(key, description, options)
end

.envsObject



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

.usageObject



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, options = {})
  Ellen.logger.info("Not implemented #{self.class}##{__method__} was called")
end

#validateObject



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