module Navigation
Adds capability to navigate through posts pages.
Public Instance Methods
ascend()
click to toggle source
Changes current Nokogiri element to its parent.
# File lib/blogbot/navigation.rb, line 32 def ascend if @current_element.ancestors.empty? == true # no more room to ascend puts 'At highest element. Nothing left to ascend.' else @current_element = @current_element.parent end end
auto_ascend()
click to toggle source
# File lib/blogbot/navigation.rb, line 40 def auto_ascend ascend until see_multiple_links? == true @current_element end
crawl_popular()
click to toggle source
Examine popular element and climb DOM tree until multiple links are present.
# File lib/blogbot/navigation.rb, line 58 def crawl_popular go_to_popular auto_ascend end
find_parent()
click to toggle source
Returns parent of current Nokogiri element
# File lib/blogbot/navigation.rb, line 27 def find_parent @parent = @current_element.parent # one element higher, the div container end
go_to_popular()
click to toggle source
Sets current element to ‘Popular’ indicator.
# File lib/blogbot/navigation.rb, line 16 def go_to_popular if see_popular? == false puts 'Nothing says "Popular" on this page' else store_indicator @current_element = @indicator @current_element end end
go_to_posts_page()
click to toggle source
Navigates to posts page based off of store_posts_url.
# File lib/blogbot/navigation.rb, line 4 def go_to_posts_page find_posts_url store_posts_url @current_page = @posts_url.click end
locate_popular_links()
click to toggle source
# File lib/blogbot/navigation.rb, line 45 def locate_popular_links if possible_success? == false ignorance_error elsif see_popular? == true crawl_popular elsif see_posts? == true go_to_posts_page see_popular? == true ? crawl_popular : ignorance_error end end
previous_page()
click to toggle source
Navigates to previous Mechanize page.
# File lib/blogbot/navigation.rb, line 11 def previous_page @current_page = @agent.get(@agent.back['href']) end