Last active
December 22, 2015 14:43
-
-
Save dadelmo/296c95bf276e6e13ea69 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' | |
def open(url) | |
Net::HTTP.get(URI.parse(url)) | |
end | |
page_content = open('http://www.loteriasyapuestas.es/servicios/premioDecimoProvisionalWeb') | |
res_json = JSON.parse(page_content) | |
ARGV.each do |num| | |
if res_json["compruebe"].map{|a| a["decimo"]}.map(&:to_i).include? num.to_i | |
val = 0 | |
res_json["compruebe"].each do |decimo| | |
val = decimo if decimo["decimo"].to_i == num.to_i | |
end | |
puts "#{num} GANADOR #{'%.2f' % ((val['prize'].to_f)/10)}€" | |
else | |
puts "#{num} PERDEDOR" | |
end | |
end | |
littlemove
commented
Dec 22, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment