Beyond using a library to parse the entire URL into protocol, hostname, path and parameters, you could use a simple regexp to extract the information. Note that the regexp is a quick and dirty solution, and it'll fail if there's anything at all different about the URL, like if it has another parameter after the v parameter.
url = 'http://www.youtube.com/watch?v=xxxxxxxxxxxxxxxxxxx'
video_id = url.match(/\?v=(.+)$/)[1]
You can go further with what you did by using URI::parse to get the query information.
url = 'http://www.youtube.com/watch?v=xxxxxxxxxxxxxxxxxxx'
video_id = CGI::parse(URI::parse(url).query)['v']