Class: AudioBookCreator::Spider
- Inherits:
-
Object
- Object
- AudioBookCreator::Spider
- Includes:
- Logging
- Defined in:
- lib/audio_book_creator/spider.rb
Instance Attribute Summary collapse
-
#page_def ⇒ Object
Returns the value of attribute page_def.
-
#web ⇒ Object
Hash access to the world wide web.
Instance Method Summary collapse
-
#initialize(page_def, web) ⇒ Spider
constructor
A new instance of Spider.
- #run(chapters) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(page_def, web) ⇒ Spider
Returns a new instance of Spider.
11 12 13 14 |
# File 'lib/audio_book_creator/spider.rb', line 11 def initialize(page_def, web) @page_def = page_def @web = web end |
Instance Attribute Details
#page_def ⇒ Object
Returns the value of attribute page_def.
9 10 11 |
# File 'lib/audio_book_creator/spider.rb', line 9 def page_def @page_def end |
#web ⇒ Object
Returns Hash access to the world wide web.
7 8 9 |
# File 'lib/audio_book_creator/spider.rb', line 7 def web @web end |
Instance Method Details
#run(chapters) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/audio_book_creator/spider.rb', line 16 def run(chapters) outstanding = CascadingArray.new([], WebPage.map_urls(chapters)) visited = [] while (url = outstanding.shift) wp = visit_page(url) visited << wp page_def.page_links(wp).each do |href| outstanding.add_unique_page(href) end page_def.chapter_links(wp).each do |href| outstanding.add_unique_chapter(href) end end visited end |