Class: Rorr::Score
- Inherits:
-
Object
show all
- Extended by:
- Base
- Defined in:
- lib/rorr/score.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Methods included from Base
generate_file_base_path, read_template, templates_path
Class Attribute Details
.finish_time ⇒ Object
Returns the value of attribute finish_time.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def finish_time
@finish_time
end
|
.report ⇒ Object
Returns the value of attribute report.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def report
@report
end
|
.single ⇒ Object
Returns the value of attribute single.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def single
@single
end
|
.start_time ⇒ Object
Returns the value of attribute start_time.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def start_time
@start_time
end
|
.time ⇒ Object
Returns the value of attribute time.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def time
@time
end
|
.total ⇒ Object
Returns the value of attribute total.
7
8
9
|
# File 'lib/rorr/score.rb', line 7
def total
@total
end
|
Class Method Details
.add_correct ⇒ Object
13
14
15
16
17
|
# File 'lib/rorr/score.rb', line 13
def add_correct
total[:correct] += 1
single[:correct] = '✓'
single[:color] = 'green'
end
|
.add_report ⇒ Object
36
37
38
|
# File 'lib/rorr/score.rb', line 36
def add_report
report << single
end
|
.add_retry ⇒ Object
31
32
33
34
|
# File 'lib/rorr/score.rb', line 31
def add_retry
total[:retry] += 1
single[:retry] += 1
end
|
.add_skip ⇒ Object
25
26
27
28
29
|
# File 'lib/rorr/score.rb', line 25
def add_skip
total[:skip] += 1
single[:skip] = '✓'
single[:color] = 'light_blue'
end
|
.add_wrong ⇒ Object
19
20
21
22
23
|
# File 'lib/rorr/score.rb', line 19
def add_wrong
total[:wrong] += 1
single[:correct] = '✗'
single[:color] = 'red'
end
|
.correct_rate ⇒ Object
44
45
46
|
# File 'lib/rorr/score.rb', line 44
def correct_rate
((total[:correct].to_f / total_count.to_f) * 100).round(2)
end
|
.export_report ⇒ Object
69
70
71
72
73
|
# 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 ⇒ Object
60
61
62
63
|
# File 'lib/rorr/score.rb', line 60
def finish
@finish_time = Time.now
@time = (finish_time - start_time).round(2)
end
|
65
66
67
|
# File 'lib/rorr/score.rb', line 65
def format_time
Time.at(Score.time).utc.strftime('%H:%M:%S')
end
|
.init(index) ⇒ Object
9
10
11
|
# File 'lib/rorr/score.rb', line 9
def init(index)
@single = { question: "#{index}.", correct: '', skip: '', retry: 0, color: '' }
end
|
.skip_rate ⇒ Object
52
53
54
|
# File 'lib/rorr/score.rb', line 52
def skip_rate
((total[:skip].to_f / total_count.to_f) * 100).round(2)
end
|
.start ⇒ Object
56
57
58
|
# File 'lib/rorr/score.rb', line 56
def start
@start_time = Time.now
end
|
.total_count ⇒ Object
40
41
42
|
# File 'lib/rorr/score.rb', line 40
def total_count
total[:correct] + total[:wrong] + total[:skip]
end
|
.wrong_rate ⇒ Object
48
49
50
|
# File 'lib/rorr/score.rb', line 48
def wrong_rate
((total[:wrong].to_f / total_count.to_f) * 100).round(2)
end
|