Class: MtgDb::Downloaders::CardDetailsDownloader

Inherits:
DownloaderBase show all
Defined in:
lib/mtg_db/downloaders.rb

Overview

Download a detailed card page given the card’s multiverse_id param Useful for double-faced cards, where we can associate the face-up and face-down cards, both on this page

Constant Summary collapse

DEBUG =
true
CARD_DETAILS_URL =
'http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=<PARAM_0>'

Constants inherited from DownloaderBase

DownloaderBase::DEFAULT_OUTPUT_DIR

Instance Attribute Summary

Attributes inherited from DownloaderBase

#agent, #output_dir

Instance Method Summary collapse

Methods inherited from DownloaderBase

#initialize, #is_empty?, #prepare_output_dir

Constructor Details

This class inherits a constructor from MtgDb::Downloaders::DownloaderBase

Instance Method Details

#start(card_name, card_multiverse_id) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/mtg_db/downloaders.rb', line 71

def start(card_name, card_multiverse_id)
  url = CARD_DETAILS_URL
  details_url = url.sub '<PARAM_0>', card_multiverse_id.to_s

  page = @agent.get(details_url)
  page_str = card_name
  save_filename = File.join(@output_dir, "#{page_str}.html")
  puts "Saving to #{save_filename}" if DEBUG
  page.save(save_filename)
end