Class: Report
- Inherits:
-
Object
- Object
- Report
- Defined in:
- lib/teuton/report/show.rb,
lib/teuton/report/close.rb,
lib/teuton/report/report.rb
Overview
This class maintain the results of every case, in a structured way.
- report/show.rb
- report/close.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#format ⇒ Object
Returns the value of attribute format.
-
#head ⇒ Hash
Report head information.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#id ⇒ Integer
It is the [Case] number.
-
#lines ⇒ Array
Report body information.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#tail ⇒ Hash
Report tail information.
Instance Method Summary collapse
-
#close ⇒ Object
Calculate final values: * grade * max_weight * good_weight,d * fail_weight * fail_counter.
-
#export(format = :txt) ⇒ Object
Export [Case] data to specified format.
-
#export_resume(format = :txt) ⇒ Object
Export resumed data from all Cases, to specified format.
-
#initialize(id = 0) ⇒ Report
constructor
Class constructor.
-
#show ⇒ Object
Display [Report] information on screen.
Constructor Details
#initialize(id = 0) ⇒ Report
Class constructor
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/teuton/report/report.rb', line 31 def initialize(id = 0) @id = id number = '0' + @id.to_s number = @id.to_s if @id > 9 @filename = "case-#{number}" @output_dir = Application.instance.output_basedir @head = {} @lines = [] @tail = {} # @history save 1 letter for every target. # For example: "..F." means: good, good, fail and good # I will use this in the future stats manager. @history = '' end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
15 16 17 |
# File 'lib/teuton/report/report.rb', line 15 def filename @filename end |
#format ⇒ Object
Returns the value of attribute format.
27 28 29 |
# File 'lib/teuton/report/report.rb', line 27 def format @format end |
#head ⇒ Hash
Returns Report head information.
18 19 20 |
# File 'lib/teuton/report/report.rb', line 18 def head @head end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
28 29 30 |
# File 'lib/teuton/report/report.rb', line 28 def history @history end |
#id ⇒ Integer
Returns It is the [Case] number. Zero indicates Resume Report.
15 16 17 |
# File 'lib/teuton/report/report.rb', line 15 def id @id end |
#lines ⇒ Array
Returns Report body information.
21 22 23 |
# File 'lib/teuton/report/report.rb', line 21 def lines @lines end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
15 16 17 |
# File 'lib/teuton/report/report.rb', line 15 def output_dir @output_dir end |
#tail ⇒ Hash
Returns Report tail information.
24 25 26 |
# File 'lib/teuton/report/report.rb', line 24 def tail @tail end |
Instance Method Details
#close ⇒ Object
Calculate final values:
- grade
- max_weight
- good_weight,d
- fail_weight
- fail_counter
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/teuton/report/close.rb', line 12 def close app = Application.instance max = 0.0 good = 0.0 fail = 0.0 fail_counter = 0 @lines.each do |i| if i.class.to_s == 'Hash' max += i[:weight] if i[:weight].positive? if i[:check] good += i[:weight] @history += app.letter[:good] else fail += i[:weight] fail_counter += 1 @history += app.letter[:bad] end end end @tail[:max_weight] = max @tail[:good_weight] = good @tail[:fail_weight] = fail @tail[:fail_counter] = fail_counter i = good.to_f / max.to_f i = 0 if i.nan? @tail[:grade] = (100.0 * i).round @tail[:grade] = 0 if @tail[:unique_fault].positive? end |
#export(format = :txt) ⇒ Object
Export [Case] data to specified format.
49 50 51 52 53 54 55 56 |
# File 'lib/teuton/report/report.rb', line 49 def export(format = :txt) @format = format filepath = File.join(@output_dir, @filename + '.' \ + FormatterFactory.ext(@format)) formatter = FormatterFactory.get(self, @format, filepath) formatter.process end |
#export_resume(format = :txt) ⇒ Object
Export resumed data from all Cases, to specified format.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/teuton/report/report.rb', line 61 def export_resume(format = :txt) @format = "resume_#{format.to_s}".to_sym filepath = File.join(@output_dir, @filename + '.' \ + FormatterFactory.ext(@format)) formatter = FormatterFactory.get(self, @format, filepath) formatter.process filepath = File.join(@output_dir, 'moodle.csv') formatter = FormatterFactory.get(self, :moodle_csv, filepath) formatter.process end |
#show ⇒ Object
Display [Report] information on screen
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/teuton/report/show.rb', line 7 def show show_initial_configurations if @filename.to_s.include? 'resume' show_resume else show_targets_history end show_final_values show_hall_of_fame end |