class NBP::XMLFilesList
Constants
- BASE_NAME
Attributes
dir_name[R]
formatted_date[R]
matched_base_file_names[R]
Public Class Methods
new(date, file_extension = '.txt')
click to toggle source
# File lib/nbp/xml_files_list.rb, line 12 def initialize(date, file_extension = '.txt') @dir_name = files_list_name(date) + file_extension @formatted_date = nbp_date_format_string(date) @matched_base_file_names = [] end
Public Instance Methods
fetch_file_names()
click to toggle source
# File lib/nbp/xml_files_list.rb, line 18 def fetch_file_names dir_file = open(Commons::CORE_WEB_PATH + dir_name, 'r') @matched_base_file_names = dir_file.each_line.with_object([]) do |line, arr| trim_line = line.strip arr << trim_line if trim_line[-6..-1] == formatted_date end end
matched_file_names_as_hashes()
click to toggle source
# File lib/nbp/xml_files_list.rb, line 26 def matched_file_names_as_hashes matched_base_file_names.map do |name| { table_name: name[0], table_number: name[1..3], constant_element: name[4], year: name[5..6], month: name[7..8], day: name[9..10], extension: name[-4..-1] } end end
Private Instance Methods
files_list_name(date)
click to toggle source
# File lib/nbp/xml_files_list.rb, line 47 def files_list_name(date) year = date.year.to_s return BASE_NAME if year[-2..-1] == DateTime.now.year.to_s[-2..-1] BASE_NAME + year end
nbp_date_format_string(date)
click to toggle source
# File lib/nbp/xml_files_list.rb, line 42 def nbp_date_format_string(date) date_hash = nbp_date_format_hash(date) date_hash[:year] + date_hash[:month] + date_hash[:day] end