Class: Parser::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/parser.rb

Constant Summary collapse

NAMES_TO_RESOURCES =
{
  /Alula_API_Documentation_([0-9]{4})-([0-9]{2})-([0-9]{2}).html/ => :reqresp,
  /Alula_Connect_Plus_API_Documentation_([0-9]{4})-([0-9]{2})-([0-9]{2}).html/ => :helix
}.freeze

Class Method Summary collapse

Class Method Details

.find_latest_file(pattern) ⇒ Object



15
16
17
# File 'lib/parser.rb', line 15

def find_latest_file(pattern)
  Dir.glob('./data/docs/*').grep(pattern).first
end

.loadObject



9
10
11
12
13
# File 'lib/parser.rb', line 9

def load
  NAMES_TO_RESOURCES.each.each_with_object({}) do |(regex, category), coll|
    coll[category] = find_latest_file(regex)
  end
end