Class: Gatherer::Scraper
- Inherits:
-
Object
- Object
- Gatherer::Scraper
- Defined in:
- lib/gatherer/scraper.rb
Constant Summary collapse
- BASE_PATH =
"http://gatherer.wizards.com"
Instance Method Summary collapse
- #expansion(name) ⇒ Object
-
#initialize(params = {}) ⇒ Scraper
constructor
A new instance of Scraper.
- #multiverse_id(id) ⇒ Object
- #page(number) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Scraper
Returns a new instance of Scraper.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gatherer/scraper.rb', line 5 def initialize(params = {}) @query = '' @subpath = '' = params.map do |k,v| send(k, v) end if @query = URI.encode(.join('&')) end end |
Instance Method Details
#expansion(name) ⇒ Object
22 23 24 25 |
# File 'lib/gatherer/scraper.rb', line 22 def expansion(name) @subpath = "/Pages/Search/Default.aspx" "set=[\"#{name}\"]" end |
#multiverse_id(id) ⇒ Object
31 32 33 34 |
# File 'lib/gatherer/scraper.rb', line 31 def multiverse_id(id) @subpath = "/Pages/Card/Details.aspx" "multiverseid=#{id}" end |
#page(number) ⇒ Object
27 28 29 |
# File 'lib/gatherer/scraper.rb', line 27 def page(number) "page=#{number}" end |
#url ⇒ Object
18 19 20 |
# File 'lib/gatherer/scraper.rb', line 18 def url BASE_PATH + @subpath + (@query.empty? ? '' : '?' + @query) end |