Sha256: 8ee51d97dfed2437e78b56dd741441936c910434e55a7139f869bdeb3c834147

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

module GoogleAjax
  module Search
    SEARCH_VERSION = 1.0
    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_web
    def self.get(method, query, args)
      args = { :v => SEARCH_VERSION }.merge(args)
      GoogleAjax::get(:search, method, query, args)
    end
  
    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_blog
    def self.blogs(query, args = {})
      self.get(:blogs, query, args)
    end
  
    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_book
    def self.books(query, args = {})
      self.get(:books, query, args)
    end

    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_image
    def self.images(query, args = {})
      self.get(:images, query, args)
    end

    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_local
    def self.local(query, latitude, longitude, args = {})
      args = { :sll => "#{latitude},#{longitude}" }.merge(args)
      self.get(:local, query, args)
    end

    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_news
    def self.news(query, args = {})
      self.get(:news, query, args)
    end

    # Arguments: http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_video
    def self.video(query, args = {})
      self.get(:video, query, args)
    end

    # http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_web
    def self.web(query, args = {})
      self.get(:web, query, args)
    end

    class Result < Base
    end

    class Page < Base
    end

    class Cursor < Base
      remap :pages => Page
    end

    class Results < Base
      remap :results => Result,
            :cursor => Cursor

      def count
        self['cursor']['estimatedResultCount'].to_i
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
googleajax-0.2.0 lib/googleajax/search.rb