Hi
Thanks for the appreciation!
Your suggestion is interesting, even though I'm not sure it would work, because:

'foobar'.parse_for_variables('foo#{name}','#{')
=> {:name=>"bar"}

works, but when you use it with double quotes string:

'foobar'.parse_for_variables("foo#{name}",'#{')
NameError: undefined local variable or method `name' for main:Object

it already tries to evaluate "name" inside the string...
so either you get retrieval or assignment right, but not both :(
Anyway, assignment is not that big a deal:

(irb) h={:year=>"2005", :user_name=>"mike", :day=>"15", :month=>"10"}
=> {:year=>"2005", :user_name=>"mike", :day=>"15", :month=>"10"}

(irb) 'ftp://ftp.org/DATA/{user_name}/{year}/{month}-{day}.txt'.gsub(/\{(.+?)\}/){h[$1.intern]}
=> "ftp://ftp.org/DATA/mike/2005/10-15.txt"

Best regards,

Eric














On 18/07/07, Pe?a, Botp <botp / delmonte-phil.com> wrote:
> From: Eric DUMINIL [mailto:eric.duminil / gmail.com]
> # For example, I would not know which file I should retrieve on:
> #  'ftp://ftp.org/DATA/mike'
> # but
> #  'ftp://ftp.org/DATA/{user_name}/{year}/{month}-{day}.txt' would do
> # just fine, so that I could, for example, get this hash:
> #  {:year=>"2005", :user_name=>"mike", :day=>"15", :month=>"10"}
> # for this filename:
> #  'ftp://ftp.org/DATA/mike/2005/10-15.txt'
>
> very nice.
> but would it be more practical if we delineate a variable just like we used to in ruby inline string; ie, use #{var} instead of just {var}
>
> this would be handy like, if i want to rename or move all folders under /mike/2005/ to /mike/2007/ eg.. the retrieval and assignment string just stay the same...
>
> kind regards -botp
>
>