Alle domenica 1 aprile 2007, Jamal Soueidan ha scritto: > Hello, > > I'm looking at URI class > http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.html > > The interface is somehow confusing? > > I tried to write > url = uri.new > url.parse!('http://www.test.com') > > but this give me error that new does not exist? > why cant I use it as a object? is the class static or is there something > i misunderstood? > > In the doc they write that parse method raise URI::InvalidURIError > incase a url is incorrect typed. > > when I try to use it, it doesn't work? > > begin > #code > rescue URI::InvalidURIError > p "wrong url" #this never happens even if the uri is empty? > end > > Thanks for your time and effort :) > > Regards, > Jamal URI is a module, not a class, so it doesn't have a new method (you can't create instances of a module). I've never used URI, so I can't be sure, but, according to the documentation, you should do: url=URI.parse('http://www.test.com') I hope this helps Stefano