class Scrapers::Imgur
Attributes
agent[RW]
download[RW]
page[RW]
url[RW]
Public Class Methods
new()
click to toggle source
# File lib/scrapers/imgur.rb, line 20 def initialize @agent = Mechanize.new @url = URI.parse(IMGUR_TEMPLATE) @download = URI.parse(IMGUR_TEMPLATE) end
Public Instance Methods
download_link(code)
click to toggle source
# File lib/scrapers/imgur.rb, line 26 def download_link(code) make_url(code) retrieve_page() find_download() @download.to_s end
find_download(link_text=/Download/)
click to toggle source
# File lib/scrapers/imgur.rb, line 41 def find_download(link_text=/Download/) link = @page.link_with(:text => link_text) raise "#{link_text} not found on #{@page.uri.to_s}" if link.nil? @download.path = link.href end
make_url(imgur_code)
click to toggle source
# File lib/scrapers/imgur.rb, line 33 def make_url(imgur_code) @url.path = "/#{imgur_code}" end
retrieve_page()
click to toggle source
# File lib/scrapers/imgur.rb, line 37 def retrieve_page() @page = @agent.get(@url.to_s) end