Class: InvestigativeReporter

Inherits:
Reporter show all
Defined in:
lib/robinson.rb

Instance Method Summary collapse

Methods inherited from Reporter

#on_see_link

Constructor Details

#initializeInvestigativeReporter

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_codeObject



90
91
92
# File 'lib/robinson.rb', line 90

def exit_code
  @broken.empty? ? success : failure
end

#failureObject



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

#successObject



93
94
95
96
# File 'lib/robinson.rb', line 93

def success
  puts "\nAll links (#{@ok.size}) check out OK."
  0
end