Sha256: 937fd1d9e7fa8da1d2b1d288392fd7ba10fb9b137bb6f878c4198346c4c7843e

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module HackerNewsSearch
  class Client
    module Search
      
      # Returns the information based on the search criteria
      #
      # @param collection [String] collection is either -  users or items 
      # @param options [Hash] A customizable set of options. 
      # @return {Hash}
      # @see http://www.hnsearch.com/api
      # @see http://www.thriftdb.com/documentation/rest-api/search-api
      # @example
      #   HackerNewsSearch.search("users" {:q => "sferik"})
      def search(collection, options={})
        get("#{collection}/_search", options)
      end
      
      # Returns the top 30 hot stories based on the Hacker News Search algorithm
      # 
      # @param options [Hash] A customizable set of options. 
      # @return {Hash}
      # @see http://www.hnsearch.com/api
      # @example
      #   HackerNewsSearch.hotness
      def hotness(options={})
        get("items/_search?limit=30&sortby=product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72)))%20desc", options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hacker_news_search-0.0.1 lib/hacker_news_search/client/search.rb