Class: GathererSetParser::Fetch
- Inherits:
-
Object
- Object
- GathererSetParser::Fetch
show all
- Includes:
- QueryString
- Defined in:
- lib/gatherer_set_parser/fetch.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#escaped_set, #gatherer_url, #initialize, #query_string, #url
Instance Attribute Details
#set_name ⇒ Object
Returns the value of attribute set_name.
9
10
11
|
# File 'lib/gatherer_set_parser/fetch.rb', line 9
def set_name
@set_name
end
|
Instance Method Details
#cards ⇒ Object
31
32
33
|
# File 'lib/gatherer_set_parser/fetch.rb', line 31
def cards
@cards ||= collect_cards
end
|
#collect_cards ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/gatherer_set_parser/fetch.rb', line 35
def collect_cards
collection = []
complete_set.each do |page|
page.css('.cardItemTable > tr > td > table').each do |card|
collection << CardParser.new(card).attributes
end
end
collection
end
|
#complete_set ⇒ Object
15
16
17
|
# File 'lib/gatherer_set_parser/fetch.rb', line 15
def complete_set
@complete_set ||= gather_set
end
|
#gather_set ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gatherer_set_parser/fetch.rb', line 19
def gather_set
set, page = [], 0
current_page = response_page page
total_pages = current_page.css('.paging > a').count
begin
set << current_page
page += 1
current_page = response_page page
end while page < total_pages - 1
set
end
|
#response_page(page) ⇒ Object
11
12
13
|
# File 'lib/gatherer_set_parser/fetch.rb', line 11
def response_page page
Nokogiri::HTML open(gatherer_url page), nil, 'UTF-8'
end
|