--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
> 
> 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?


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


irb(main):007:0> require 'uri'
=> true
irb(main):008:0> url = 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")
=> #<URI::HTTP:0xfdbe7c2fe URL:http://www.booger.com>


-- 
Michael T. Richter <ttmrichter / 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
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="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.12.1">
</HEAD>
<BODY>
On Sun, 2007-01-04 at 20:42 +0900, Jamal Soueidan wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">I'm looking at URI class</FONT>
<FONT COLOR="#000000">http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/index.html</FONT>

<FONT COLOR="#000000">The interface is somehow confusing?</FONT>

<FONT COLOR="#000000">I tried to write</FONT>
<FONT COLOR="#000000">url = uri.new</FONT>
<FONT COLOR="#000000">url.parse!('http://www.test.com')</FONT>

<FONT COLOR="#000000">but this give me error that new does not exist?</FONT>
</PRE>
</BLOCKQUOTE>
<BR>
To me it looks like &quot;uri&quot; doesn't exist:<BR>
<BR>
<PRE>
<TT>irb(main):007:0&gt; require 'uri'</TT>
<TT>=&gt; true</TT>
<TT>irb(main):008:0&gt; url = uri.new</TT>
<TT>NameError: undefined local variable or method `uri' for main:Object</TT>
<TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from (irb):8</TT>
<TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from /usr/lib/ruby/1.8/uri/http.rb:56</TT>
</PRE>
<BR>
Glancing at the page you posted, I see there that there is no object calledquot;uri&quot; anywhere.&nbsp; There is a <B>module</B> called &quot;URI&quot; and it has a parse method, but there isn't a class you can instantiate.&nbsp; What's returned from that method (there also doesn't appear to be a &quot;parse!&quot; method anywhere on that page) looks like it's one of the URI::&lt;something&gt; classes for each specific protocol like URI::HTTPnd the like.<BR>
<BR>
<PRE>
<TT>irb(main):009:0&gt; URI.parse(&quot;http://www.booger.com&quot;)</TT>
<TT>=&gt; #&lt;URI::HTTP:0xfdbe7c2fe URL:http://www.booger.com&gt;</TT>
</PRE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
<B>Michael T. Richter</B> &lt;ttmrichter / gmail.com&gt; (<B>GoogleTalk:</B> ttmrichter / gmail.com)<BR>
<I>All really first class designers are both artists, engineers, and men ofowerful 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)</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/j3ZWGFX4ozU
-----END PGP SIGNATURE-----

--QRXBY5+CcWi4cC9rOxt--