Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Black_H http://blackh.badfile.net/wordz/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

ARGV Parser

This function parse ARGV and return a string.
See exemples for more informations :

// Go : http://blackh.badfile.net/wordz/

Function :

   1  
   2    def options(param)
   3    
   4  	i = 0
   5  		ARGV.each  { |valeur|
   6  		
   7      		if (valeur == '-' + param.to_s)
   8  				return ARGV[i+1]
   9  			elseif (valeur != '-' + param.to_s)
  10  				return false
  11  			end
  12  		i += 1
  13  		}
  14  		
  15     end


Usage :

// cmd> ruby test.rb -o foo
   1  
   2  
   3  	out =  self.options('o')
   4  
   5  	if (out != false and out.empty? == false)
   6                     puts out # print -> foo
   7  	end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS