class FeedSearcher::Fetcher

Attributes

options[R]
url[R]

Public Class Methods

fetch(*args) click to toggle source
# File lib/feed_searcher/fetcher.rb, line 3
def self.fetch(*args)
  new(*args).fetch
end
new(url, options = {}) click to toggle source
# File lib/feed_searcher/fetcher.rb, line 9
def initialize(url, options = {})
  @url     = url
  @options = options
end

Public Instance Methods

fetch() click to toggle source
# File lib/feed_searcher/fetcher.rb, line 14
def fetch
  Page.new(get)
end

Private Instance Methods

agent() click to toggle source
# File lib/feed_searcher/fetcher.rb, line 24
def agent
  Mechanize.new.tap do |mechanize|
    mechanize.open_timeout = options[:open_timeout] if options[:open_timeout]
    mechanize.read_timeout = options[:read_timeout] if options[:read_timeout]
    mechanize.user_agent   = options[:user_agent]   if options[:user_agent]
  end
end
get() click to toggle source
# File lib/feed_searcher/fetcher.rb, line 20
def get
  agent.get(url)
end