module BLZ
Constants
- DATA_FILE
Public Class Methods
convert_file_to_date(f)
click to toggle source
# File lib/blz.rb, line 13 def self.convert_file_to_date(f) match = f.match(/(?<y>\d{4})_(?<m>\d\d)_(?<d>\d\d)\.tsv\.gz$/) Date.new match[:y].to_i, match[:m].to_i, match[:d].to_i end
find_data_file(now=Date.today)
click to toggle source
# File lib/blz.rb, line 18 def self.find_data_file(now=Date.today) glob = Dir[ File.join(File.dirname(__FILE__), '../data/*.tsv.gz') ].sort file = glob.find {|c| now <= convert_file_to_date(c) } || glob.last # sanity check if now < Date.new(2016, 3, 6) || now > (convert_file_to_date(file) + 90) warn [now] warn '[BLZ] The data provided may not be accurate.' end file end