--=-/QRXBY5+CcWi4cC9rOxt
Content-Type: multipart/alternative; boundary="=-+PlINj5Z+oR8cJDzaE6y"
--=-+PlINj5Z+oR8cJDzaE6y
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
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::<something> classes for each specific protocol like URI::HTTP and
the like.
irb(main):009:0> URI.parse("
http://www.booger.com")
=3D> #<URI::HTTP:0xfdbe7c2fe URL:
http://www.booger.com>
--=20
Michael T. Richter <
[email protected]> (GoogleTalk:
(e-mail address removed))
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; CHARSET=3DUTF-8">
<META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.12.1">
</HEAD>
<BODY>
On Sun, 2007-01-04 at 20:42 +0900, Jamal Soueidan wrote:
<BLOCKQUOTE TYPE=3DCITE>
<PRE>
<FONT COLOR=3D"#000000">I'm looking at URI class</FONT>
<FONT COLOR=3D"#000000"><A HREF=3D"
http://www.ruby-doc.org/stdlib/libdoc/ur=
i/rdoc/index.html">
http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.htm=
l</A></FONT>
<FONT COLOR=3D"#000000">The interface is somehow confusing?</FONT>
<FONT COLOR=3D"#000000">I tried to write</FONT>
<FONT COLOR=3D"#000000">url =3D uri.new</FONT>
<FONT COLOR=3D"#000000">url.parse!('<A HREF=3D"
http://www.test.com">
http://=
www.test.com</A>')</FONT>
<FONT COLOR=3D"#000000">but this give me error that new does not exist?</FO=
NT>
</PRE>
</BLOCKQUOTE>
<BR>
To me it looks like "uri" doesn't exist:<BR>
<BR>
<PRE>
<TT>irb(main):007:0> require 'uri'</TT>
<TT>=3D> true</TT>
<TT> from (irb):8</TT>
<TT> from /usr/lib/ruby/1.8/uri/h=
ttp.rb:56</TT>
</PRE>
<BR>
Glancing at the page you posted, I see there that there is no object called=
"uri" anywhere. There is a <B>module</B> 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.<BR>
<BR>
<PRE>
<TT>irb(main):009:0> URI.parse("<A HREF=3D"
http://www.booger.com">h=
ttp://
www.booger.com</A>"
</TT>
<TT>=3D> #<URI::HTTP:0xfdbe7c2fe URL:<A HREF=3D"
http://www.booger.com=
">
http://www.booger.com</A>></TT>
</PRE>
<BR>
<TABLE CELLSPACING=3D"0" CELLPADDING=3D"0" WIDTH=3D"100%">
<TR>
<TD>
-- <BR>
<B>Michael T. Richter</B> <<A HREF=3D"mailto:
[email protected]">ttmri=
(e-mail address removed)</A>> (<B>GoogleTalk:</B> (e-mail address removed))<BR>
<I>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)</I>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
--=-+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--