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 = "00") ⇒ Report
constructor
Class constructor.
-
#show ⇒ Object
Display [Report] information on screen.
Constructor Details
#initialize(id = "00") ⇒ Report
Class constructor
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/teuton/report/report.rb', line 32 def initialize(id = "00") @id = id @filename = "case-#{@id}" @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.
16 17 18 |
# File 'lib/teuton/report/report.rb', line 16 def filename @filename end |
#format ⇒ Object
Returns the value of attribute format.
28 29 30 |
# File 'lib/teuton/report/report.rb', line 28 def format @format end |
#head ⇒ Hash
Returns Report head information.
19 20 21 |
# File 'lib/teuton/report/report.rb', line 19 def head @head end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
29 30 31 |
# File 'lib/teuton/report/report.rb', line 29 def history @history end |
#id ⇒ Integer
Returns It is the [Case] number. Zero indicates Resume Report.
16 17 18 |
# File 'lib/teuton/report/report.rb', line 16 def id @id end |
#lines ⇒ Array
Returns Report body information.
22 23 24 |
# File 'lib/teuton/report/report.rb', line 22 def lines @lines end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
16 17 18 |
# File 'lib/teuton/report/report.rb', line 16 def output_dir @output_dir end |
#tail ⇒ Hash
Returns Report tail information.
25 26 27 |
# File 'lib/teuton/report/report.rb', line 25 def tail @tail end |
Instance Method Details
#close ⇒ Object
Calculate final values:
-
grade
-
max_weight
-
good_weight,d
-
fail_weight
-
fail_counter
9 10 11 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 |
# File 'lib/teuton/report/close.rb', line 9 def close app = Application.instance max = 0.0 good = 0.0 fail = 0.0 fail_counter = 0 @lines.each do |i| next unless i.instance_of? 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 @tail[:max_weight] = max @tail[:good_weight] = good @tail[:fail_weight] = fail @tail[:fail_counter] = fail_counter i = good.to_f / max 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.
48 49 50 51 52 53 54 55 |
# File 'lib/teuton/report/report.rb', line 48 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.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/teuton/report/report.rb', line 60 def export_resume(format = :txt) @format = "resume_#{format}".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 |