module Reflection
Adds capability to examine for posts, articles, and links.
Public Instance Methods
possible_success?()
click to toggle source
Determines if bot can crawl a Popular section. If it doesn’t see popular at first glance, it searches and navigates to Posts page (Articles or Blog).
If Popular section still doesn’t exist, it’s a no-go.
# File lib/blogbot/reflection.rb, line 35 def possible_success? if see_popular? == true true elsif see_posts? == true go_to_posts_page # Changes page to look for popular. answer = see_popular? == true ? true : false # true if popular is present previous_page # Check is complete. Return to original page. answer else false end end
see_links?()
click to toggle source
Searches for presence of <a> tags in current element.
# File lib/blogbot/reflection.rb, line 20 def see_links? @current_element.css('a').empty? ? false : true end
see_multiple_links?()
click to toggle source
Searches for presences of more than two <a> tags in current element.
# File lib/blogbot/reflection.rb, line 25 def see_multiple_links? @current_element.css('a').length < 3 ? false : true end
see_popular?()
click to toggle source
Searches for keyword ‘Popular’ on current page.
# File lib/blogbot/reflection.rb, line 14 def see_popular? search = @current_page.search "[text()*='Popular']" search.empty? ? false : true end
see_posts?()
click to toggle source
Searches for link that says articles or blog.
# File lib/blogbot/reflection.rb, line 4 def see_posts? find_posts_url if @article_link.nil? == true && @blog_link.nil? == true false # => no article links found else true end end