Sha256: 3135a500e904433c39b17dde7e984054242caabcdaccb57df689234b80f31580
Contents?: true
Size: 802 Bytes
Versions: 1
Compression:
Stored size: 802 Bytes
Contents
class Sfn::Search attr_reader :results, :root_url, :loader def initialize(root_url, loader) @root_url = root_url ? root_url : "http://api.getsatisfaction.com" @loader = loader @results = {} end def for_likely_matches_to(name, entities = %w(companies products)) @results = entities.inject({}) {|hash, entity| #raise @root_url.inspect query_string = "#{@root_url}/#{entity}.json?q=#{name}" #result = Net::HTTP.get_response(URI.parse(query_string)).body answer = @loader.get(query_string) if answer[0] == :ok result = answer[1] #raise result.inspect hash.merge({entity => JSON.parse(result)['data']}) else raise "Search service not available at the moment, please try again later." end } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pius-ruby-satisfaction-0.4.2 | lib/satisfaction/search.rb |