Class: ParseDecision::Controller
- Inherits:
-
Object
- Object
- ParseDecision::Controller
- Defined in:
- lib/parse_decision/controller.rb
Overview
Controller class handles interactions bewteen the view (cmdline script) and the model (Tool).
Instance Method Summary collapse
-
#execute ⇒ Object
Save the current config values and start the parse.
-
#executeWithCmdLineArg(arg) ⇒ Object
Command line arg will be used as the
outdir
. -
#initialize ⇒ Controller
constructor
A new instance of Controller.
-
#noCmdLineArg ⇒ Object
Make sure
outdir
has been set. -
#setOptions(options = {}) ⇒ Object
Set all options and switches with values from a hash.
Constructor Details
Instance Method Details
#execute ⇒ Object
Save the current config values and start the parse.
31 32 33 34 35 36 37 |
# File 'lib/parse_decision/controller.rb', line 31 def execute() $LOG.debug "Controller::execute" # Save current cfg Config.new.save( @cfg ) @model.parseCfg( @cfg ) end |
#executeWithCmdLineArg(arg) ⇒ Object
Command line arg will be used as the outdir
.
115 116 117 118 119 |
# File 'lib/parse_decision/controller.rb', line 115 def executeWithCmdLineArg(arg) $LOG.debug "Controller::executeWithCmdLineArg( #{arg} )" @cfg[:outdir] = arg return true # if ok to continue, false to exit app. end |
#noCmdLineArg ⇒ Object
Make sure outdir
has been set. Returns true as long as outdir is set one way or the other.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/parse_decision/controller.rb', line 124 def noCmdLineArg() $LOG.debug "Controller::noCmdLineArg" if( @cfg.key?(:outdir) && !@cfg[:outdir].empty? ) return true # if ok to continue, false to exit app. end puts "Missing output directory argument." puts puts "The outdir needs to be set at least one time." puts "Use the -o option or supply the output directory path on the command line." puts "Use -h for help." return false # to exit app. end |
#setOptions(options = {}) ⇒ Object
Set all options and switches with values from a hash.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/parse_decision/controller.rb', line 80 def setOptions(={}) $LOG.debug "Controller::setOptions( options={} )" setSwitches() if(.length) .each do |opt, arg| case opt when :file # Set cfg decision file name @cfg[:file] = arg when :outdir # Set context output dir @cfg[:outdir] = arg when :srcdir # Set context src dir @cfg[:srcdir] = arg else # Don't know what you want but I don't recognize it. end end # options.each cfgCtrl = Config.new cfgCtrl.load cfgCtrl.cfg.merge!(@cfg) cfgCtrl.save end # if more than 1 option end |