Class: MedievalLatina::Lexicon
- Inherits:
-
Object
- Object
- MedievalLatina::Lexicon
- Defined in:
- lib/medieval_latina/lexicon.rb
Constant Summary collapse
- LEXICON_DIR =
File.("../../lexicons", __dir__)
Class Method Summary collapse
- .file_names_with_contents ⇒ Object
- .get_file_content(file_name) ⇒ Object
- .get_file_path(file_name) ⇒ Object
- .list_files ⇒ Object
Class Method Details
.file_names_with_contents ⇒ Object
20 21 22 23 24 25 |
# File 'lib/medieval_latina/lexicon.rb', line 20 def self.file_names_with_contents list_files.each_with_object({}) do |file_path, files_content| file_name, extension = File.basename(file_path).split(".") files_content[file_name] = get_file_content("#{file_name}.#{extension}") end end |
.get_file_content(file_name) ⇒ Object
15 16 17 18 |
# File 'lib/medieval_latina/lexicon.rb', line 15 def self.get_file_content(file_name) path = get_file_path(file_name) File.read(path) end |
.get_file_path(file_name) ⇒ Object
9 10 11 12 13 |
# File 'lib/medieval_latina/lexicon.rb', line 9 def self.get_file_path(file_name) path = File.join(LEXICON_DIR, file_name) return path if File.exist?(path) raise "Lexicon file not found: #{file_name}" end |
.list_files ⇒ Object
5 6 7 |
# File 'lib/medieval_latina/lexicon.rb', line 5 def self.list_files Dir.glob(File.join(LEXICON_DIR, "*.pls")) end |