Class: Page
Constant Summary collapse
- ATTEMPTS =
3
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#register ⇒ Object
readonly
Returns the value of attribute register.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #fatal(error) ⇒ Object
- #hash ⇒ Object
-
#initialize(register, url, source) ⇒ Page
constructor
A new instance of Page.
- #intermittent(error) ⇒ Object
- #success ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(register, url, source) ⇒ Page
Returns a new instance of Page.
8 9 10 11 12 13 14 |
# File 'lib/crawl/page.rb', line 8 def initialize(register, url, source) @register = register @url = url @source = source @attempts = 0 @errors = nil end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/crawl/page.rb', line 4 def error @error end |
#register ⇒ Object (readonly)
Returns the value of attribute register.
4 5 6 |
# File 'lib/crawl/page.rb', line 4 def register @register end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
4 5 6 |
# File 'lib/crawl/page.rb', line 4 def source @source end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/crawl/page.rb', line 4 def url @url end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 |
# File 'lib/crawl/page.rb', line 16 def <=>(other) url <=> other.url end |
#eql?(other) ⇒ Boolean
20 21 22 |
# File 'lib/crawl/page.rb', line 20 def eql?(other) url.eql?(other.url) end |
#fatal(error) ⇒ Object
33 34 35 36 37 |
# File 'lib/crawl/page.rb', line 33 def fatal(error) puts " Fatal - #{error}" if $VERBOSE @error = error @register.completed(self) end |
#hash ⇒ Object
24 25 26 |
# File 'lib/crawl/page.rb', line 24 def hash url.hash end |
#intermittent(error) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/crawl/page.rb', line 39 def intermittent(error) puts " Intermittent - #{error}" if $VERBOSE if @attempts >= ATTEMPTS @error = error @register.completed(self) else @attempts += 1 @register.retry(self) end end |
#success ⇒ Object
28 29 30 31 |
# File 'lib/crawl/page.rb', line 28 def success @error = nil @register.completed(self) end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/crawl/page.rb', line 50 def to_s "#{url} found on #{source} - #{error || 'OK'}" end |