Sha256: ed30aa29ff2c2011c85335e823772915f9d9c6ae7d4eaa9331f69c4a1bc51098

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 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" "sferik")
      #   HackerNewsSearch.search("users", "sferik" {:limit => "30"})
      #   HackerNewsSearch.search("items" "jobs")
      def search(collection, query, options={})
        get("#{collection}/_search?q=#{query}", 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

5 entries across 5 versions & 1 rubygems

Version Path
hacker_news_search-0.0.7 lib/hacker_news_search/client/search.rb
hacker_news_search-0.0.6 lib/hacker_news_search/client/search.rb
hacker_news_search-0.0.5 lib/hacker_news_search/client/search.rb
hacker_news_search-0.0.4 lib/hacker_news_search/client/search.rb
hacker_news_search-0.0.3 lib/hacker_news_search/client/search.rb