Class: BaseFormatter
- Inherits:
-
Object
- Object
- BaseFormatter
- Defined in:
- lib/teuton/report/formatter/base_formatter.rb
Overview
BaseFormatter class
Direct Known Subclasses
ArrayFormatter, CSVFormatter, ResumeArrayFormatter, XMLFormatter
Instance Method Summary collapse
-
#deinit ⇒ Object
Close open output file.
-
#init(filename) ⇒ Object
Creates new output file.
-
#initialize(report) ⇒ BaseFormatter
constructor
Initialize class.
-
#process ⇒ Object
Execute format action.
- #trim(input) ⇒ Object
-
#w(text) ⇒ Object
Write data into output file.
Constructor Details
#initialize(report) ⇒ BaseFormatter
Initialize class
8 9 10 11 12 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 8 def initialize(report) @head = report.head @lines = report.lines @tail = report.tail end |
Instance Method Details
#deinit ⇒ Object
Close open output file
37 38 39 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 37 def deinit @file.close end |
#init(filename) ⇒ Object
Creates new output file
23 24 25 26 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 23 def init(filename) @filename = filename @file = File.open(@filename, 'w') end |
#process ⇒ Object
Execute format action
16 17 18 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 16 def process raise 'Empty method!' end |
#trim(input) ⇒ Object
41 42 43 44 45 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 41 def trim(input) output = input.to_s output = "...#{input[input.size - 50, input.size]}" if output.size > 65 output.to_s end |
#w(text) ⇒ Object
Write data into output file
31 32 33 |
# File 'lib/teuton/report/formatter/base_formatter.rb', line 31 def w(text) @file.write text.to_s end |