-
-
Save pragmaticivan/7767d3c79b067444a03f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
uri = URI('http://divulga.tse.jus.br/2014/divulgacao/oficial/143/dadosdivweb/br/br-0001-e001431-w.js') | |
class String; def percent_of(n) "#{(self.to_f / n.to_f * 100.0).round(2)}%"; end; end | |
begin | |
data = JSON(Net::HTTP.get_response(uri).body) | |
system('clear') | |
puts "\n\n----\n#{data['ht']} - #{data['ea'].percent_of(data['e'])} dos votos apurados\n----" | |
data['cand'].take(3).each do |candidate| | |
puts "[#{candidate['n']}] #{candidate['nm']} - #{candidate['v'].percent_of(data['vv'])}" | |
end | |
end while sleep(60) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
uri = URI('http://divulga.tse.jus.br/2014/divulgacao/oficial/144/dadosdivweb/br/br-0001-e001441-w.js') | |
class String; def percent_of(n) "#{(self.to_f / n.to_f * 100.0).round(2)}%"; end; end | |
begin | |
data = JSON(Net::HTTP.get_response(uri).body) | |
system('clear') | |
puts "\n\n----\n#{data['ht']} - #{data['ea'].percent_of(data['e'])} dos votos apurados\n----" | |
data['cand'].each do |candidate| | |
puts "[#{candidate['n']}] #{candidate['nm']} - #{candidate['v'].percent_of(data['vv'])}" | |
end | |
end while sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment