How do I make this more Ruby like? I want to return the host, for example if the URL is "http://www.facebook.com" then I want to get 'facebook.com'.
Any other sub-domains without 'www' should give the subdomin as well. If the URL is "http://gist.github.com" then I want 'gist.github.com':
def get_domain
a = @url.split('.')
a[-1] = a[-1].gsub(/\//,'')
if a[0][-3..-1] == "www"
a.delete_at(0)
else
a[0] = a[0].gsub(/https?:\/\//,'')
end
domain = a.join('.')
domain
rescue => e
puts e.message
end #end of get_domain