class Phi::Losophy::Pages
Constants
- InfiniteLoop
- MaximumPages
Attributes
browsed[R]
losophy[R]
pages[R]
Public Class Methods
new(losophy)
click to toggle source
# File lib/phi/losophy/pages.rb, line 10 def initialize(losophy) @losophy = losophy @pages = [] end
Public Instance Methods
current_page()
click to toggle source
# File lib/phi/losophy/pages.rb, line 19 def current_page @current_page || self.current_page = first_page end
each() { |next until philosophy?| ... }
click to toggle source
# File lib/phi/losophy/pages.rb, line 15 def each yield self.next until current_page.philosophy? end
next()
click to toggle source
# File lib/phi/losophy/pages.rb, line 23 def next infinite_loop! max_pages! self.current_page = current_page.next end
Private Instance Methods
current_page=(page)
click to toggle source
# File lib/phi/losophy/pages.rb, line 37 def current_page=(page) pages << @current_page = page end
first_page()
click to toggle source
# File lib/phi/losophy/pages.rb, line 33 def first_page @first_page ||= Page.new(term, connection) end
infinite_loop!()
click to toggle source
# File lib/phi/losophy/pages.rb, line 46 def infinite_loop! return unless pages.map(&:term).include? current_page.next_term raise InfiniteLoop.new("#{current_page.next_term} would enter an infinite loop and will not hit philosophy") end
max_pages!()
click to toggle source
# File lib/phi/losophy/pages.rb, line 41 def max_pages! return if pages.count < Phi.max raise MaximumPages.new("Max pages (#{pages.count}) have been crawled") end