Question : Ruby script failing: (NoMethodError)

I have the following script:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
#!/usr/bin/env ruby

# Credentials
COIN_USERNAME = 'changeme'
COIN_PASSWORD = 'changeme'

# Directory to store files in
COIN_DIRECTORY = '/tmp/coin'
# Windows example:
# COIN_DIRECTORY = 'C:\\temp' 

# Pages to fetch and links to follow
COIN_FILES = {
  'mobielenummers.html' => [
    'Mobiele Nummer Reeksen (laatste versie)',
    'Mobiele Nummers (laatste versie)'
  ],
  'geografischenummers.html' => [
    'Geografische Nummer Reeksen (laatste versie)',
    'Geografische Nummers (laatste versie)'
  ],
  'servicenummers.html' => [
    ['Service Nummers (laatste versie)', 2]
  ]
}


require 'rubygems'
require 'mechanize'

websession = WWW::Mechanize.new

COIN_FILES.each_pair do |path, links|
  url = "http://www.coin.nl/#{path}"
  puts "Opening #{url}"
  indexpage = websession.get url
  
  loginform = indexpage.form 'loginform'
  if loginform
    loginform.txtUID = COIN_USERNAME
    loginform.txtPWD = COIN_PASSWORD
    puts "Logging in"
    indexpage = websession.submit loginform, loginform.buttons.first
  end
  
  links.each do |linkspec|
    if linkspec.is_a? Array
      linktext, linkindex = linkspec
      linkindex -= 1
    else
      linktext = linkspec
      linkindex = 0
    end
    
    websession.transact do
      link = indexpage.links.text linktext
      link = link[linkindex] if link.is_a? Array
      puts "Following link #{link.uri}"
      page = websession.click link
      
      # page.filename is surrounded by quotes!
      filename = File.basename page.filename[1..-2]
      filename = File.expand_path filename, COIN_DIRECTORY
      puts " => Saving to #{filename}"
      page.save filename
      puts "Decompressing"
      raise if not system "uncompress '#{filename}'"
    end
  end
end
puts 'Done.'


it constantly fails with:
---
Opening http://www.coin.nl/geografischenummers.html
/usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/ssl_resolver.rb:19:in `handle': undefined method `instance_variable_defined?' for #<Net::HTTP www.coin.nl:80 open=false> (NoMethodError)
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain.rb:29:in `pass'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/handler.rb:6:in `handle'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/connection_resolver.rb:73:in `handle'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain.rb:29:in `pass'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/handler.rb:6:in `handle'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/request_resolver.rb:26:in `handle'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain.rb:29:in `pass'
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize/chain/handler.rb:6:in `handle'
         ... 6 levels...
        from /usr/lib64/ruby/gems/1.8/gems/mechanize-1.0.0/lib/mechanize.rb:259:in `get'
        from ./coin_download.rb:34
        from ./coin_download.rb:31:in `each_pair'
        from ./coin_download.rb:31
---

I have ruby 1.8.5.

Any idea?

Answer : Ruby script failing: (NoMethodError)

You are using <a href="http://mechanize.rubyforge.org/mechanize/">The Mechanize library</a>, but it requires ruby 1.8.6. So, you should upgrade Ruby
Random Solutions  
 
programming4us programming4us