Class: Mago::Detector
- Inherits:
-
Object
- Object
- Mago::Detector
- Defined in:
- lib/mago/detector.rb
Overview
Magic numbers detector.
Constant Summary collapse
- DEFAULT_IGNORE =
Numbers which are ignored by default
[0, 1]
Instance Method Summary collapse
-
#initialize(file_paths = [], options = {}) ⇒ Detector
constructor
A new instance of Detector.
-
#on_error(&block) ⇒ Object
Set callback to be called when error occurs.
-
#on_file(&block) ⇒ Object
Set callback to be called when file processing is finished.
-
#run ⇒ Mago::Report
Process files and build a report.
Constructor Details
#initialize(file_paths = [], options = {}) ⇒ Detector
Returns a new instance of Detector.
15 16 17 18 19 |
# File 'lib/mago/detector.rb', line 15 def initialize(file_paths = [], = {}) @file_paths = file_paths @report = Report.new @ignore = [:ignore] || DEFAULT_IGNORE end |
Instance Method Details
#on_error(&block) ⇒ Object
Set callback to be called when error occurs.
37 38 39 |
# File 'lib/mago/detector.rb', line 37 def on_error(&block) @on_error = block end |
#on_file(&block) ⇒ Object
Set callback to be called when file processing is finished.
32 33 34 |
# File 'lib/mago/detector.rb', line 32 def on_file(&block) @on_file = block end |
#run ⇒ Mago::Report
Process files and build a report.
24 25 26 27 28 29 |
# File 'lib/mago/detector.rb', line 24 def run @file_paths.each do |path| process_file(path) end @report end |