Class: Page

Inherits:
Object
  • Object
show all
Defined in:
lib/robinson.rb

Instance Method Summary collapse

Constructor Details

#initialize(anemone_page) ⇒ Page

Returns a new instance of Page.



105
106
107
# File 'lib/robinson.rb', line 105

def initialize(anemone_page)
  @page = anemone_page
end

Instance Method Details

#broken?Boolean

Returns:

  • (Boolean)


123
124
125
126
127
128
# File 'lib/robinson.rb', line 123

def broken?
  if unfetchable?
    return true 
  end
  @page.code >= 400
end

#pagelog(what, code) ⇒ Object



117
118
119
# File 'lib/robinson.rb', line 117

def pagelog(what, code)
    "#{what}: #{@page.url} - #{code} (referer: #{@page.referer})"
end

#putsObject



108
109
110
111
112
113
114
115
116
# File 'lib/robinson.rb', line 108

def puts
  if unfetchable?
    $stdout.puts(pagelog("BROKEN!!", 'no http response').colored.red)
  elsif broken?
    $stdout.puts(pagelog("BROKEN!!", @page.code).colored.red)
  else
    $stdout.puts(pagelog("checked", @page.code).colored.green)
  end
end

#unfetchable?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/robinson.rb', line 120

def unfetchable?
  @page.code.nil?
end