Class: Swat::Parameters
- Inherits:
-
Object
- Object
- Swat::Parameters
- Defined in:
- lib/swat.rb
Overview
Parameters parsing helper class
Assumes the first parameter to be the execution mode (dryrun or execute) Assumes the second parameter to be the script name Captures the rest as arguments that are piped in to the script
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#command ⇒ Object
Returns the value of attribute command.
-
#execution_mode ⇒ Object
Returns the value of attribute execution_mode.
Instance Method Summary collapse
-
#initialize(args = ARGV.clone) ⇒ Parameters
constructor
A new instance of Parameters.
- #to_s ⇒ Object
Constructor Details
#initialize(args = ARGV.clone) ⇒ Parameters
Returns a new instance of Parameters.
83 84 85 86 87 88 89 |
# File 'lib/swat.rb', line 83 def initialize(args = ARGV.clone) @args = args @execution_mode = @args.shift @command = @args.shift fail "Execution mode is mandatory" if @execution_mode.nil? fail "No command was specified" if @command.nil? end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
81 82 83 |
# File 'lib/swat.rb', line 81 def args @args end |
#command ⇒ Object
Returns the value of attribute command.
81 82 83 |
# File 'lib/swat.rb', line 81 def command @command end |
#execution_mode ⇒ Object
Returns the value of attribute execution_mode.
81 82 83 |
# File 'lib/swat.rb', line 81 def execution_mode @execution_mode end |
Instance Method Details
#to_s ⇒ Object
91 92 93 |
# File 'lib/swat.rb', line 91 def to_s "#{@execution_mode} #{@command} #{@args.inspect}" end |