[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

creating directory "http://example.com"

Comfort Eagle

11/29/2006 8:53:00 PM

How do I create a directory 'http://exampl... without it getting
broken up because of the '/'s ?


url = 'http://example...
Dir.mkdir(url)

--
Posted via http://www.ruby-....

14 Answers

Paul Lutus

11/29/2006 9:47:00 PM

0

Comfort Eagle wrote:

> How do I create a directory 'http://exampl... without it getting
> broken up because of the '/'s ?

Very simply, you can't. That is an URL, not a directory path.

Insteda of asking this hypothetical question about a hypothetical solution,
please state the problem to be solved and someone will help you.

--
Paul Lutus
http://www.ara...

Comfort Eagle

11/29/2006 10:05:00 PM

0

Paul Lutus wrote:
> Comfort Eagle wrote:
>
>> How do I create a directory 'http://exampl... without it getting
>> broken up because of the '/'s ?
>
> Very simply, you can't. That is an URL, not a directory path.
>
> Insteda of asking this hypothetical question about a hypothetical
> solution,
> please state the problem to be solved and someone will help you.

Hmm, ok then. How could I strip http:// from that string?

--
Posted via http://www.ruby-....

Paul Lutus

11/29/2006 10:24:00 PM

0

Comfort Eagle wrote:

> Paul Lutus wrote:
>> Comfort Eagle wrote:
>>
>>> How do I create a directory 'http://exampl... without it getting
>>> broken up because of the '/'s ?
>>
>> Very simply, you can't. That is an URL, not a directory path.
>>
>> Insteda of asking this hypothetical question about a hypothetical
>> solution,
>> please state the problem to be solved and someone will help you.
>
> Hmm, ok then. How could I strip http:// from that string?

string.sub!(%r{http://},"")

--
Paul Lutus
http://www.ara...

James Britt

11/29/2006 10:26:00 PM

0

On 11/29/06, Comfort Eagle <steve@fooworks.com> wrote:

> Hmm, ok then. How could I strip http:// from that string?
>
> --
url = 'http://exampl...
url.gsub!( /^http:\/\//i, '')



James

Comfort Eagle

11/30/2006 12:46:00 AM

0

James Britt wrote:
> On 11/29/06, Comfort Eagle <steve@fooworks.com> wrote:
>
>> Hmm, ok then. How could I strip http:// from that string?
>>
>> --
> url = 'http://exampl...
> url.gsub!( /^http:\/\//i, '')
>
>
>
> James

Interesting. Newb Q, I'm sure, but when I put that in a while loop I
get: "private method `gsub!' called for ..." /me googles & still
scratches head.

"
res.each do |url|
puts url.gsub!( /^http:\/\//i, '')
end
"

--
Posted via http://www.ruby-....

Paul Lutus

11/30/2006 2:04:00 AM

0

Comfort Eagle wrote:

/ ...

> Interesting. Newb Q, I'm sure, but when I put that in a while loop I
> get: "private method `gsub!' called for ..." /me googles & still
> scratches head.
>
> "
> res.each do |url|
> puts url.gsub!( /^http:\/\//i, '')
> end

What is "res"? Is it an array of strings?

Also, it is sometimes easier to use the %r{...} syntax instead of /.../,
this allows you to use "/" as an ordinary character.

--
Paul Lutus
http://www.ara...

Comfort Eagle

11/30/2006 2:05:00 AM

0

Troy Denkinger wrote:
> Does this work for you?
>
> "http://www.test.com&... do |url|
> puts url.gsub!( /^http:\/\//i, '')
> end

Yes. Re-evaluating my assumptions....

--
Posted via http://www.ruby-....

Comfort Eagle

11/30/2006 2:11:00 AM

0

Paul Lutus wrote:
> Comfort Eagle wrote:
>
> / ...
>
>> Interesting. Newb Q, I'm sure, but when I put that in a while loop I
>> get: "private method `gsub!' called for ..." /me googles & still
>> scratches head.
>>
>> "
>> res.each do |url|
>> puts url.gsub!( /^http:\/\//i, '')
>> end
>
> What is "res"? Is it an array of strings?

I thought it was:
res = dbh.query("Select url FROM sites")

--
Posted via http://www.ruby-....

Comfort Eagle

11/30/2006 2:34:00 AM

0

Comfort Eagle wrote:
> Paul Lutus wrote:
>> Comfort Eagle wrote:
>>
>> / ...
>>
>>> Interesting. Newb Q, I'm sure, but when I put that in a while loop I
>>> get: "private method `gsub!' called for ..." /me googles & still
>>> scratches head.
>>>
>>> "
>>> res.each do |url|
>>> puts url.gsub!( /^http:\/\//i, '')
>>> end
>>
>> What is "res"? Is it an array of strings?

Better:
I thought it was array of strings & looks like it to me??

res = dbh.query("Select url FROM sites")
while url = res.fetch_row do
puts url.gsub!( /^http:\/\//i, '')
end

--
Posted via http://www.ruby-....

dblack

11/30/2006 2:49:00 AM

0