Module: BLZ
- Defined in:
- lib/blz.rb,
lib/blz/bank.rb
Defined Under Namespace
Classes: Bank
Constant Summary collapse
- DATA_FILE =
find_data_file
Class Method Summary collapse
Class Method Details
.convert_file_to_date(f) ⇒ Object
13 14 15 16 |
# 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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |