Class: Recog::MatchReporter
- Inherits:
-
Object
- Object
- Recog::MatchReporter
- Defined in:
- lib/recog/match_reporter.rb
Instance Attribute Summary collapse
-
#fail_count ⇒ Object
readonly
Returns the value of attribute fail_count.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#line_count ⇒ Object
readonly
Returns the value of attribute line_count.
-
#match_count ⇒ Object
readonly
Returns the value of attribute match_count.
Instance Method Summary collapse
- #failure(text) ⇒ Object
- #increment_line_count ⇒ Object
-
#initialize(options, formatter) ⇒ MatchReporter
constructor
A new instance of MatchReporter.
- #match(text) ⇒ Object
- #print_summary ⇒ Object
- #report {|_self| ... } ⇒ Object
- #stop? ⇒ Boolean
Constructor Details
#initialize(options, formatter) ⇒ MatchReporter
Returns a new instance of MatchReporter.
6 7 8 9 10 |
# File 'lib/recog/match_reporter.rb', line 6 def initialize(, formatter) @options = @formatter = formatter reset_counts end |
Instance Attribute Details
#fail_count ⇒ Object (readonly)
Returns the value of attribute fail_count.
4 5 6 |
# File 'lib/recog/match_reporter.rb', line 4 def fail_count @fail_count end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
3 4 5 |
# File 'lib/recog/match_reporter.rb', line 3 def formatter @formatter end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
4 5 6 |
# File 'lib/recog/match_reporter.rb', line 4 def line_count @line_count end |
#match_count ⇒ Object (readonly)
Returns the value of attribute match_count.
4 5 6 |
# File 'lib/recog/match_reporter.rb', line 4 def match_count @match_count end |
Instance Method Details
#failure(text) ⇒ Object
32 33 34 35 |
# File 'lib/recog/match_reporter.rb', line 32 def failure(text) @fail_count += 1 formatter.(text) end |
#increment_line_count ⇒ Object
23 24 25 |
# File 'lib/recog/match_reporter.rb', line 23 def increment_line_count @line_count += 1 end |
#match(text) ⇒ Object
27 28 29 30 |
# File 'lib/recog/match_reporter.rb', line 27 def match(text) @match_count += 1 formatter.(text) end |
#print_summary ⇒ Object
37 38 39 |
# File 'lib/recog/match_reporter.rb', line 37 def print_summary colorize_summary(summary_line) end |
#report {|_self| ... } ⇒ Object
12 13 14 15 16 |
# File 'lib/recog/match_reporter.rb', line 12 def report reset_counts yield self summarize unless @options.quiet end |
#stop? ⇒ Boolean
18 19 20 21 |
# File 'lib/recog/match_reporter.rb', line 18 def stop? return false unless @options.fail_fast @fail_count >= @options.stop_after end |