Skip to content

Instantly share code, notes, and snippets.

@crm114
Forked from tallclouds/resultados.rb
Created November 13, 2012 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crm114/4069184 to your computer and use it in GitHub Desktop.
Save crm114/4069184 to your computer and use it in GitHub Desktop.
Resultados Elecciones de Puerto Rico en Ruby
#!/usr/bin/env ruby
# sudo port install jp2a (Mac OS X)
# sudo apt-get install jp2a (Ubuntu/Debian)
# gem install httparty
# gem install hashie
# gem install hirb
class Candidate
@@base_url = 'http://207.150.251.12/REYDI_NocheDelEvento/'
def initialize(name, votes, photo)
@name = name
@votes = votes
@photo = photo
end
def name
@name
end
def votes
@votes
end
def photo
unless @name == "*OTROS"
system("jp2a --width=120 #{@@base_url + @photo}")
sleep(1)
end
"scroll up"
end
end
require 'httparty'
require 'hashie'
require 'hirb'
extend Hirb::Console
base_url = 'http://207.150.251.12/REYDI_NocheDelEvento/'
results = Hashie::Mash.new(HTTParty.get(base_url + '/data/GOBERNADOR_ISLA.xml'))
candidates = results["default"].option.collect {|candidate| Candidate.new(candidate.name.es, candidate.votes, candidate.img.reverse.chop.chop.reverse)}
table candidates, :fields=>[:name, :votes, :photo]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment