Class: Mago::Formatter
- Inherits:
-
Object
- Object
- Mago::Formatter
- Defined in:
- lib/mago/formatter.rb
Instance Method Summary collapse
- #format ⇒ Object
- #format_error(error, out) ⇒ Object
- #format_file(file, out) ⇒ Object
-
#initialize(report) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(report) ⇒ Formatter
Returns a new instance of Formatter.
3 4 5 |
# File 'lib/mago/formatter.rb', line 3 def initialize(report) @report = report end |
Instance Method Details
#format ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mago/formatter.rb', line 7 def format out = '' @report.files.each do |file| format_file(file, out) end @report.errors.each do |error| format_error(error, out) end out end |
#format_error(error, out) ⇒ Object
27 28 29 |
# File 'lib/mago/formatter.rb', line 27 def format_error(error, out) out << "ERROR: %s\n" % [error] end |
#format_file(file, out) ⇒ Object
21 22 23 24 25 |
# File 'lib/mago/formatter.rb', line 21 def format_file(file, out) file.magic_numbers.each do |num| out << "%s:%d detected magic number %s\n" % [file.path, num.line, num.value] end end |