Yes, in Ruby’s standard library you’ll find a whole module of classes for working with URI’s. There’s one for HTTP. You can call #build
with some arguments, much like you showed.
http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI/HTTP.html#M009497
For the query string itself, just use Rails’ Hash addition #to_query
. i.e.
uri = URI::HTTP.build(:host => "www.google.com", :query => { :q => "test" }.to_query)