Sha256: 4fbfc5e7eea2e9f3db141ed2b6ce7e50883a2678c9014fe9b543c97fed76c54c
Contents?: true
Size: 825 Bytes
Versions: 1
Compression:
Stored size: 825 Bytes
Contents
require 'rest-client' module Lita module Handlers class OnewheelElectionCnn < Handler route /^e[rl]ection/i, :election, command: true, help: {'election' => 'Display the current election results.'} def election(response) Lita.logger.debug 'get_source started' results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json')) results['candidates'].each do |candidate| candidate_str = "#{candidate['fname']} #{candidate['lname']}: " candidate_str += "WINNER! " if candidate['winner'] candidate_str += "#{candidate['pctDecimal']}%, #{candidate['vpct']}% of precincts reporting." response.reply candidate_str end end Lita.register_handler(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-onewheel-election-cnn-0.0.0 | lib/lita/handlers/onewheel_election_cnn.rb |