class Blogbot

Make a new blogbot that can scan pages and extract the most popular links!

Attributes

agent[RW]
article_link[RW]
current_element[RW]
current_page[RW]
indicator[RW]
parent[RW]
posts_url[RW]
target_url[RW]

Public Class Methods

new() click to toggle source
# File lib/blogbot.rb, line 32
def initialize
  puts 'Powering up the rubatron generators!!'
  set_agent
  @current_page = nil
  @current_element = nil
  @popular_links = []
  @indicator = nil
end

Public Instance Methods

ignorance_error() click to toggle source
# File lib/blogbot.rb, line 55
def ignorance_error
  fail "Sorry, either there are no popular links present
        or this bot isn't smart enough to extract this site yet\n"
end
reset() click to toggle source
# File lib/blogbot.rb, line 47
def reset
  set_agent
  @current_page = nil
  @current_element = nil
  @popular_links = []
  @indicator = nil
end
scan(url) click to toggle source

GET a page using Mechanize and set to current page.

# File lib/blogbot.rb, line 42
def scan(url)
  @target_url = url
  @current_page = @agent.get(@target_url)
end
set_agent() click to toggle source
# File lib/blogbot.rb, line 28
def set_agent
  self.agent = Mechanize.new { |a| a.user_agent_alias = 'Mac Safari' }
end