Module: Studium::Exams::Dataset
- Defined in:
- lib/studium/exams/dataset.rb
Overview
Studium::Exams::Dataset
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === Studium::Exams::Dataset[].
Class Method Details
.[](i = '') ⇒ Object
#
Studium::Exams::Dataset[]
This is the recommended way to initialize the exam-dataset.
#
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/studium/exams/dataset.rb', line 32 def self.[](i = '') all_arrays = [] all_exam_files = Dir["#{Studium.exam_topics?}*"] # ======================================================================= # # Sometimes we may have an erroneous file, such as a file ending with # '~'. We will display a warning in this case, but otherwise we will # continue. # ======================================================================= # if all_exam_files.any? {|entry| entry.end_with?('~') } puts 'At the least one file of the exam dataset ends with a ~ token.' puts 'It is recommended to not use trailing ~ characters there.' puts "The directory is at: #{DIRECTORY_EXAM_TOPICS}" end all_exam_files.each {|file| dataset = File.readlines(file) all_arrays << ::Studium.filter_away_invalid_questions(dataset, file) } return all_arrays.flatten # Return the huge Array here. end |