class Gnu
Parse the parameter hash using the GNU standard.
Public Instance Methods
parse()
click to toggle source
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. @return [Array] Gnu-style parsed params in a string array.
# 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