From: "Michael T. Richter" Date: 2007-04-01T22:46:05+09:00 Subject: Re: How to use standard library? --=-/QRXBY5+CcWi4cC9rOxt Content-Type: multipart/alternative; boundary="=-+PlINj5Z+oR8cJDzaE6y" --=-+PlINj5Z+oR8cJDzaE6y Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sun, 2007-01-04 at 20:42 +0900, Jamal Soueidan wrote: > I'm looking at URI class > http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.html >=20 > The interface is somehow confusing? >=20 > I tried to write > url =3D uri.new > url.parse!('http://www.test.com') >=20 > but this give me error that new does not exist? To me it looks like "uri" doesn't exist: irb(main):007:0> require 'uri' =3D> true irb(main):008:0> url =3D uri.new NameError: undefined local variable or method `uri' for main:Object from (irb):8 from /usr/lib/ruby/1.8/uri/http.rb:56 Glancing at the page you posted, I see there that there is no object called "uri" anywhere. There is a module called "URI" and it has a parse method, but there isn't a class you can instantiate. What's returned from that method (there also doesn't appear to be a "parse!" method anywhere on that page) looks like it's one of the URI:: classes for each specific protocol like URI::HTTP and the like. irb(main):009:0> URI.parse("http://www.booger.com") =3D> # --=20 Michael T. Richter (GoogleTalk: ttmrichter@gmail.com) All really first class designers are both artists, engineers, and men of a powerful and intolerant temper, quick to resist the least modification of the plans, energetic in fighting the least infringement upon what they regard as their own sphere of action. (Nevil Shute) --=-+PlINj5Z+oR8cJDzaE6y Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, 2007-01-04 at 20:42 +0900, Jamal Soueidan wrote:
I'm looking at URI class
http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.htm=
l

The interface is somehow confusing?

I tried to write
url =3D uri.new
url.parse!('http://=
www.test.com')

but this give me error that new does not exist?

To me it looks like "uri" doesn't exist:

irb(main):007:0> require 'uri'
=3D> true
irb(main):008:0> url =3D uri.new
NameError: undefined local variable or method `uri' for main:Object
        from (irb):8
        from /usr/lib/ruby/1.8/uri/h=
ttp.rb:56

Glancing at the page you posted, I see there that there is no object called= "uri" anywhere.  There is a module called "URI&= quot; and it has a parse method, but there isn't a class you can instantiat= e.  What's returned from that method (there also doesn't appear to be = a "parse!" method anywhere on that page) looks like it's one of t= he URI::<something> classes for each specific protocol like URI::HTTP= and the like.

irb(main):009:0> URI.parse("h=
ttp://www.booger.com")
=3D> #<URI::HTTP:0xfdbe7c2fe URL:http://www.booger.com>

--
Michael T. Richter <ttmri= chter@gmail.com> (GoogleTalk: ttmrichter@gmail.com)
All really first class designers are both artists, engineers, and men of= a powerful and intolerant temper, quick to resist the least modification o= f the plans, energetic in fighting the least infringement upon what they re= gard as their own sphere of action. (Nevil Shute)
--=-+PlINj5Z+oR8cJDzaE6y-- --=-/QRXBY5+CcWi4cC9rOxt Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBGD6WILqyWkKVQ54QRAoE2AJ9FEIHTCN0l+USPGrCLO9oY6dLDXgCeKo4J x8Q4Jcu9Ewmuq/j3ZWGFX4o= =hfzU -----END PGP SIGNATURE----- --=-/QRXBY5+CcWi4cC9rOxt--