Class: Gnu
- Inherits:
-
CommandParser
- Object
- CommandParser
- Gnu
- Defined in:
- lib/runnable/gnu.rb
Overview
Parse the parameter hash using the GNU standard.
Instance Method Summary collapse
-
#parse ⇒ Array
This method convert a hash in an array of strings ready to be passed to a command that uses GNU style to parse command line parameters.
Methods inherited from CommandParser
Constructor Details
This class inherits a constructor from CommandParser
Instance Method Details
#parse ⇒ Array
This method convert a hash in an array of strings ready to be passed to a command that uses GNU style to parse command line parameters.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/runnable/gnu.rb', line 27 def parse @params.collect do |param, value| # We assume that an one character words is preceed by one # lead and two or more characters words are preceed by two # leads option = ( param.length == 1 ? "-#{param}" : "--#{param}" ) # In case the param have parameter we use the correct assignation # -Param followed by value (whitout whitespace) to one character params # -Param followed by '=' and value to more than one character params if( value != nil ) option.concat( param.length == 1 ? "#{value}" : "=#{value}" ) end option end end |