Class: Phi::Losophy::Pages
- Inherits:
-
Object
- Object
- Phi::Losophy::Pages
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/phi/losophy/pages.rb
Instance Attribute Summary collapse
-
#browsed ⇒ Object
readonly
Returns the value of attribute browsed.
-
#losophy ⇒ Object
readonly
Returns the value of attribute losophy.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
Instance Method Summary collapse
- #browsed? ⇒ Boolean
- #current_page ⇒ Object
- #each ⇒ Object
-
#initialize(losophy) ⇒ Pages
constructor
A new instance of Pages.
- #next ⇒ Object
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
#browsed ⇒ Object (readonly)
Returns the value of attribute browsed.
7 8 9 |
# File 'lib/phi/losophy/pages.rb', line 7 def browsed @browsed end |
#losophy ⇒ Object (readonly)
Returns the value of attribute losophy.
7 8 9 |
# File 'lib/phi/losophy/pages.rb', line 7 def losophy @losophy end |
#pages ⇒ Object (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
30 31 32 |
# File 'lib/phi/losophy/pages.rb', line 30 def browsed? browsed.include? current_page.term end |
#current_page ⇒ Object
34 35 36 |
# File 'lib/phi/losophy/pages.rb', line 34 def current_page @current_page || self.current_page = first_page end |
#each ⇒ Object
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 |
#next ⇒ Object
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 |