lib/gscraper/sponsored_ad.rb in gscraper-0.1.7 vs lib/gscraper/sponsored_ad.rb in gscraper-0.2.0

- old
+ new

@@ -1,5 +1,27 @@ +# +#-- +# GScraper - A web-scraping interface to various Google Services. +# +# Copyright (c) 2007-2008 Hal Brodigan (postmodern.mod3 at gmail.com) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#++ +# + require 'gscraper/extensions/uri' module GScraper class SponsoredAd @@ -12,17 +34,19 @@ # # Creates a new SponsoredAd with the specified _title_ and _url_. # def initialize(title,url) @title = title - @url = URI.parse(url) + @url = url end # # Returns the direct URL of the ad. # def direct_url - @url.query_params['adurl'] || @url.query_params['q'] + uri = URI(@url) + + return (uri.query_params['adurl'] || uri.query_params['q']) end # # Returns the title of the ad. #