class QuickExam::Analyst::BaseText
Attributes
records[R]
total_line[R]
Public Class Methods
new(file_path, f_ques:'' , f_corr:'')
click to toggle source
# File lib/quick_exam/analyst/base_text.rb, line 12 def initialize(file_path, f_ques:'' , f_corr:'') raise ErrorAnalyze.new('No such file') unless File.exist? file_path @file_path = file_path @f_ques = f_ques @f_corr = f_corr @records = QuickExam::RecordCollection.new() end
Public Instance Methods
analyze()
click to toggle source
# File lib/quick_exam/analyst/base_text.rb, line 20 def analyze data_standardize self rescue => e raise ErrorAnalyze.new('Data can not analyze') end
Private Instance Methods
data_standardize()
click to toggle source
# File lib/quick_exam/analyst/base_text.rb, line 31 def data_standardize file = File.open(@file_path, 'r') @total_line = File.foreach(file).count @object = QuickExam::Record.new() file.each_line.with_index do |row, idx| idx += 1 # The first row is 1 if end_of_line?(idx) || end_of_one_ticket_for_next_question?(row) get_answer(row) # if the last line is answer then will get answer collect_object_ticket end next if row.__blank? next if get_answer(row) next if get_question(row) end records end