Sha256: 2867c73ca19b736f75bc338c93a18ca934c6fc1cc7886a4de9a5b5bf06a1fb96
Contents?: true
Size: 832 Bytes
Versions: 4
Compression:
Stored size: 832 Bytes
Contents
require 'socialinvestigator/client/hn' module Socialinvestigator module CLI class Hn < Thor desc "search URL", "Search hn.algolia.com for a url mentioned on Hackernews" option :tags def search( url ) result = client.search_by_date( url, options[:tag] ).parsed_response puts "#{result['nbHits']} Hits" result['hits'].each do |hit| puts "#{hit['title']}#{hit['story_title']}" puts " #{hit['url']}" if hit['url'] != "" puts " #{hit['points']} points" puts " #{hit['num_comments']} comments" if hit['num_comments'] puts " https://news.ycombinator.com/item?id=#{hit['objectID']}" puts end end private def client @client ||= Socialinvestigator::Client::Hn.new end end end end
Version data entries
4 entries across 4 versions & 1 rubygems