Class: InvestigativeReporter
Instance Method Summary collapse
- #exit_code ⇒ Object
- #failure ⇒ Object
-
#initialize ⇒ InvestigativeReporter
constructor
A new instance of InvestigativeReporter.
- #on_visit(page) ⇒ Object
- #success ⇒ Object
Methods inherited from Reporter
Constructor Details
#initialize ⇒ InvestigativeReporter
Returns a new instance of InvestigativeReporter.
78 79 80 81 |
# File 'lib/robinson.rb', line 78 def initialize @broken = [] @ok = [] end |
Instance Method Details
#exit_code ⇒ Object
90 91 92 |
# File 'lib/robinson.rb', line 90 def exit_code @broken.empty? ? success : failure end |
#failure ⇒ Object
97 98 99 100 101 |
# File 'lib/robinson.rb', line 97 def failure puts "\nBroken links (#{@broken.size} out of #{@ok.size}):" @broken.each { |page| page.puts } @broken.size end |
#on_visit(page) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/robinson.rb', line 82 def on_visit(page) if page.broken? @broken << page else @ok << page end page.puts end |
#success ⇒ Object
93 94 95 96 |
# File 'lib/robinson.rb', line 93 def success puts "\nAll links (#{@ok.size}) check out OK." 0 end |