Last active
December 13, 2015 18:08
-
-
Save Janther/4952754 to your computer and use it in GitHub Desktop.
Función para acceder al valor de la UF de cualquier fecha.
This file contains 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 'nokogiri' | |
require 'open-uri' | |
def uf date = nil | |
date ||= Date.today | |
year = date.year | |
month = date.month | |
day = date.mday | |
sii_uf = "http://www.sii.cl/pagina/valores/uf/uf#{year}.htm" | |
uf_table = Nokogiri::HTML open(sii_uf) | |
uf = uf_table.css("table tbody tr")[day-1].css("td")[month-1].text.gsub(".", "").gsub(",", ".").to_f | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment