Class: Arxiv::Downloader::Categories

Inherits:
Object
  • Object
show all
Defined in:
lib/arxiv/downloader/categories.rb

Constant Summary collapse

DATA_PATH =
File.expand_path('categories.yaml', __dir__).freeze

Instance Method Summary collapse

Constructor Details

#initializeCategories

Returns a new instance of Categories.



8
9
10
# File 'lib/arxiv/downloader/categories.rb', line 8

def initialize
  @data = YAML.load_file(DATA_PATH)
end

Instance Method Details

#lookup(id) ⇒ Object



12
13
14
15
16
17
# File 'lib/arxiv/downloader/categories.rb', line 12

def lookup id
  entry = @data[id]
  return nil if entry.nil?

  { id: id, name: entry['name'], group: entry['group'], description: entry['description'] }
end