Module: JamesBond::Core::Mission
- Included in:
- HelpMission
- Defined in:
- lib/james_bond/core/mission.rb,
lib/james_bond/core/mission/undefined_variable_error.rb
Defined Under Namespace
Classes: MissionConfig, UndefinedVariableError
Instance Attribute Summary collapse
-
#core_mission_config ⇒ Object
Returns the value of attribute core_mission_config.
-
#core_mission_options ⇒ Object
Returns the value of attribute core_mission_options.
-
#option_rules ⇒ Object
readonly
Returns the value of attribute option_rules.
Instance Method Summary collapse
- #arguments_parser {|@option_rules| ... } ⇒ Object
- #build(config, params) ⇒ Object
- #initialize(params = {}) ⇒ Object
- #run_command(command:, mission_pool:) ⇒ Object
Instance Attribute Details
#core_mission_config ⇒ Object
Returns the value of attribute core_mission_config.
8 9 10 |
# File 'lib/james_bond/core/mission.rb', line 8 def core_mission_config @core_mission_config end |
#core_mission_options ⇒ Object
Returns the value of attribute core_mission_options.
8 9 10 |
# File 'lib/james_bond/core/mission.rb', line 8 def @core_mission_options end |
#option_rules ⇒ Object (readonly)
Returns the value of attribute option_rules.
11 12 13 |
# File 'lib/james_bond/core/mission.rb', line 11 def option_rules @option_rules end |
Instance Method Details
#arguments_parser {|@option_rules| ... } ⇒ Object
35 36 37 38 39 |
# File 'lib/james_bond/core/mission.rb', line 35 def arguments_parser(&block) require "slop" @option_rules = Slop::Options.new yield(@option_rules) end |
#build(config, params) ⇒ Object
22 23 24 |
# File 'lib/james_bond/core/mission.rb', line 22 def build(config, params) raise(NotImplementedError, "The method \"build\" must be implemented for the #{self.class} class") end |
#initialize(params = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/james_bond/core/mission.rb', line 13 def initialize(params={}) @core_mission_config = MissionConfig.new @core_mission_options = {} build(@core_mission_config, params) check_variables_definitions check_main_command_methods end |
#run_command(command:, mission_pool:) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/james_bond/core/mission.rb', line 26 def run_command(command: , mission_pool:) @core_mission_options = command. = parse_arguments(command) if @option_rules command. = parse_arguments(command) if @option_rules self.send( build_command_method_name(command.main_command), { command: command, mission_pool: mission_pool } ) end |