title: Ruby + Option parser
body: <p>I am learning option parsing in ruby by referring <a href="http://www.ruby-doc.org/stdlib-2.0.0/libdoc/optparse/rdoc/OptionParser.html" rel="nofollow">this</a> and <a href="http://ruby.about.com/od/advancedruby/a/optionparser.htm" rel="nofollow">this</a>. This is my test code:</p>
  
  <pre><code>#!/usr/bin/ruby
  require "optparse"
  
  options = {}
  
  optparse = OptionParser.new do |opts|
    opts.banner = "Learning Option parsing in Ruby"
  
    opts.on("-i", "--ipaddress", "IP address of the server") do |ipaddr|
      options[:ipaddress] =  ipaddr
    end
  
      opts.on("-u", "--username", "username to log in") do |user|
        options[:username] = user
      end
  
      opts.on("-p", "--password", "password of the user") do |pass|
        options[:password] = pass
      end
  end
  
  optparse.parse!
  
  puts "the IPaddress is #{options[:ipaddress]}" if options[:ipaddress]
  puts "the username is #{options[:username]}" if options[:username]
  puts "the password is #{options[:password]}" if options[:password]
  </code></pre>
  
  <p>My intention is to print the opton that I am passing to the script. However, it doens't print the option that I pass, instead just says <code>true</code>:</p>
  
  <pre><code># ruby getops.rb  --ipaddress 1.1.1.1
  the IPaddress is true
  # ruby getops.rb  --username user1
  the username is true
  # ruby getops.rb  --password secret
  the password is true
  </code></pre>
  
  <p>Where am I going wrong? I tried with the short options as well , but the result is same.</p>