Re: GetoptLong Accessing the values with out looping

Makes perfect sense in this example you are still looping
through the options. All though this is better on the eyes.

I was hoping that the instance of getoptlong had some kind of
method to get the value of one of the command line options.

Paul

Yes, it sucks. That’s why I wrote the ‘getopt’ package.

gem install getopt :slight_smile:

require ‘getopt/long’
include Getopt

opts = Getopt::Long.new([’-d’, ‘–date’, REQUIRED])

if opts[‘d’]

end

Regards,

Dan

This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.

On Tue, 16 May 2006, Berger, Daniel wrote:

Makes perfect sense in this example you are still looping

Dan

nice dan. i’ve been using optparse for all my stuff but it’s usage is a
bit
obtuse. perhaps i’ll switch… does it support parsing arbitrary arrays
or
only ARGV?

regards.

-a

Yes, it sucks. That’s why I wrote the ‘getopt’ package.

gem install getopt :slight_smile:

require ‘getopt/long’
include Getopt

I am having an issue with the script working. Is their some path
variable
that needs to be set for ruby to see the gem packages?

Initially i have the ubuntu ruby pkgs installed. I have removed them and
built ruby 1.8.4 and gems 0.8.11 built from source.

Any ideas?

*kraus@pkraus-laptop:~/sandbox/ruby/Daily Reports$ ./phones.rb
./phones.rb:3:in `require’: no such file to load – getopt/long
(LoadError)
from ./phones.rb:3

kraus@pkraus-laptop:~/rubygems-0.8.11$ sudo gem install getopt
Attempting local installation of ‘getopt’
Local gem file not found: getopt*.gem
Attempting remote installation of ‘getopt’
Updating Gem source index for: http://gems.rubyforge.org
Successfully installed getopt-1.3.4
Installing RDoc documentation for getopt-1.3.4…