Just discovered this today but the URI concatenation in Ruby is fantastic. Fantastic to the extent that you can take a host URL add it to a relative URL and produce an absolute URL for that resource. For example:

u=URI.parse("http://www.chart-track.co.uk/?i=756&s=1111")
a=u+"/assets/images/m/modernwarfare2hangson_797_2.jpg"
a.to_s
>> "http://www.chart-track.co.uk/assets/images/m/modernwarfare2hangson_797_2.jpg"

via Eric Hodel

blog comments powered by Disqus