Module: CLI::Mastermind::Plan::Interface
- Extended by:
- Forwardable
- Included in:
- CLI::Mastermind::Plan
- Defined in:
- lib/cli/mastermind/plan/interface.rb
Overview
The plan interface is everything that is required in order for an object to be usable as a plan.
Objects adhering to this interface must implement their own call method. This method is what is invoked by Mastermind to execute a plan.
Mastermind assumes that any plan it encounters could have children, hence the has_children? method here. Since the default PlanfileLoader doesn’t permit custom plan classes when defining a plan with children, it’s assumed that any custom plans (which include this interface) won’t have any children at all.
Class Method Summary collapse
Instance Method Summary collapse
- #call(options = nil) ⇒ Object
- #has_children? ⇒ Boolean
- #initialize(name, description = nil, filename = nil, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cli/mastermind/plan/interface.rb', line 17 def self.included(base) # The name of the plan. Used to specify the plan from the command line # or from the interactive menu base.attr_reader :name # Displayed in the non-interactive list of available plans base.attr_reader :description # The file this plan was loaded from, if any base.attr_reader :filename end |
Instance Method Details
#call(options = nil) ⇒ Object
40 41 42 |
# File 'lib/cli/mastermind/plan/interface.rb', line 40 def call(=nil) raise NotImplementedError end |
#has_children? ⇒ Boolean
36 37 38 |
# File 'lib/cli/mastermind/plan/interface.rb', line 36 def has_children? false end |
#initialize(name, description = nil, filename = nil, &block) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/cli/mastermind/plan/interface.rb', line 29 def initialize(name, description=nil, filename=nil, &block) @name = name.to_s.freeze @description = description.freeze @filename = filename @block = block end |