Class: Phi::Losophy::Pages

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/phi/losophy/pages.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(losophy) ⇒ Pages

Returns a new instance of Pages.



9
10
11
12
13
# File 'lib/phi/losophy/pages.rb', line 9

def initialize(losophy)
  @losophy = losophy
  @pages   = []
  @browsed = []
end

Instance Attribute Details

#browsedObject (readonly)

Returns the value of attribute browsed.



7
8
9
# File 'lib/phi/losophy/pages.rb', line 7

def browsed
  @browsed
end

#losophyObject (readonly)

Returns the value of attribute losophy.



7
8
9
# File 'lib/phi/losophy/pages.rb', line 7

def losophy
  @losophy
end

#pagesObject (readonly)

Returns the value of attribute pages.



7
8
9
# File 'lib/phi/losophy/pages.rb', line 7

def pages
  @pages
end

Instance Method Details

#browsed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/phi/losophy/pages.rb', line 30

def browsed?
  browsed.include? current_page.term
end

#current_pageObject



34
35
36
# File 'lib/phi/losophy/pages.rb', line 34

def current_page
  @current_page || self.current_page = first_page
end

#eachObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/phi/losophy/pages.rb', line 15

def each 
  until current_page.philosophy?
    if browsed?
      puts "#{current_page.term} has entered ani infinite loop and will not hit philosophy"
      puts "The Philosophy Index in this case will reflect the pages from #{term} to the loop causing #{current_page.term}"
      break
    else 
      puts "Now browsing #{current_page.term}"
      yield self.next
      guard_max_pages!
    end
  end
    puts "Found Philosophy" unless browsed? 
end

#nextObject



38
39
40
41
# File 'lib/phi/losophy/pages.rb', line 38

def next
  browsed << current_page.term
  self.current_page = current_page.next
end