Class: QuickExam::Analyzer
- Includes:
- Format
- Defined in:
- lib/quick_exam/analyzer.rb
Constant Summary
Constants included from Format
Format::ALLOWED_ELEMENTS, Format::CORRECT_MARK, Format::FOLDER_NAME_EXPORT, Format::QUESTION_MARK
Instance Attribute Summary collapse
-
#f_corr ⇒ Object
readonly
Returns the value of attribute f_corr.
-
#f_ques ⇒ Object
readonly
Returns the value of attribute f_ques.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#total_line ⇒ Object
readonly
Returns the value of attribute total_line.
Instance Method Summary collapse
- #analyze ⇒ Object
- #docx? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(file_path, f_ques: '', f_corr: '') ⇒ Analyzer
constructor
A new instance of Analyzer.
- #txt? ⇒ Boolean
Methods included from Format
Constructor Details
#initialize(file_path, f_ques: '', f_corr: '') ⇒ Analyzer
Returns a new instance of Analyzer.
11 12 13 14 15 16 |
# File 'lib/quick_exam/analyzer.rb', line 11 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.__presence || QUESTION_MARK @f_corr = f_corr.__presence || CORRECT_MARK end |
Instance Attribute Details
#f_corr ⇒ Object (readonly)
Returns the value of attribute f_corr.
9 10 11 |
# File 'lib/quick_exam/analyzer.rb', line 9 def f_corr @f_corr end |
#f_ques ⇒ Object (readonly)
Returns the value of attribute f_ques.
9 10 11 |
# File 'lib/quick_exam/analyzer.rb', line 9 def f_ques @f_ques end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
9 10 11 |
# File 'lib/quick_exam/analyzer.rb', line 9 def records @records end |
#total_line ⇒ Object (readonly)
Returns the value of attribute total_line.
9 10 11 |
# File 'lib/quick_exam/analyzer.rb', line 9 def total_line @total_line end |
Instance Method Details
#analyze ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/quick_exam/analyzer.rb', line 18 def analyze case when txt? then process_base_text when docx? then process_base_docx when html? then process_base_html end end |
#docx? ⇒ Boolean
34 35 36 |
# File 'lib/quick_exam/analyzer.rb', line 34 def docx? File.extname(@file_path) == '.docx' end |
#html? ⇒ Boolean
30 31 32 |
# File 'lib/quick_exam/analyzer.rb', line 30 def html? File.extname(@file_path) == '.html' end |
#txt? ⇒ Boolean
26 27 28 |
# File 'lib/quick_exam/analyzer.rb', line 26 def txt? File.extname(@file_path) == '.txt' end |