class Rorr::Score
Attributes
finish_time[R]
report[R]
single[R]
start_time[R]
time[R]
total[R]
Public Class Methods
add_correct()
click to toggle source
# File lib/rorr/score.rb, line 13 def add_correct total[:correct] += 1 single[:correct] = '✓' single[:color] = 'green' end
add_report()
click to toggle source
# File lib/rorr/score.rb, line 36 def add_report report << single end
add_retry()
click to toggle source
# File lib/rorr/score.rb, line 31 def add_retry total[:retry] += 1 single[:retry] += 1 end
add_skip()
click to toggle source
# File lib/rorr/score.rb, line 25 def add_skip total[:skip] += 1 single[:skip] = '✓' single[:color] = 'light_blue' end
add_wrong()
click to toggle source
# File lib/rorr/score.rb, line 19 def add_wrong total[:wrong] += 1 single[:correct] = '✗' single[:color] = 'red' end
correct_rate()
click to toggle source
# File lib/rorr/score.rb, line 44 def correct_rate ((total[:correct].to_f / total_count.to_f) * 100).round(2) end
export_report()
click to toggle source
# File lib/rorr/score.rb, line 69 def export_report File.open(generate_file_base_path + '/Report', 'w') do |f| f.write read_template(templates_path + '/report.erb') end end
finish()
click to toggle source
# File lib/rorr/score.rb, line 60 def finish @finish_time = Time.now @time = (finish_time - start_time).round(2) end
format_time()
click to toggle source
# File lib/rorr/score.rb, line 65 def format_time Time.at(Score.time).utc.strftime('%H:%M:%S') end
init(index)
click to toggle source
# File lib/rorr/score.rb, line 9 def init(index) @single = { question: "#{index}.", correct: '', skip: '', retry: 0, color: '' } end
skip_rate()
click to toggle source
# File lib/rorr/score.rb, line 52 def skip_rate ((total[:skip].to_f / total_count.to_f) * 100).round(2) end
start()
click to toggle source
# File lib/rorr/score.rb, line 56 def start @start_time = Time.now end
total_count()
click to toggle source
# File lib/rorr/score.rb, line 40 def total_count total[:correct] + total[:wrong] + total[:skip] end
wrong_rate()
click to toggle source
# File lib/rorr/score.rb, line 48 def wrong_rate ((total[:wrong].to_f / total_count.to_f) * 100).round(2) end