Class: ComixScraper::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/comix_scraper/parser.rb

Constant Summary collapse

CATEGORIES =
['DARK HORSE COMICS', 'DC COMICS','IDW PUBLISHING','IMAGE COMICS','MARVEL COMICS','COMICS','MAGAZINES','MERCHANDISE']

Instance Method Summary collapse

Instance Method Details

#parse(data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/comix_scraper/parser.rb', line 7

def parse(data)

  release_data = ComixScraper::ReleaseData.new

  current_section = ""
  data.each_with_index { | value, index |

    release_data.categories << value && current_section = value if CATEGORIES.include?value

    values = value.split('\t')
    
    next if values.length != 3
    
    id = values[0]
    title = values[1]
    rrp = values[2]
    release_data.comix << Comic.new(current_section, id, title, rrp)
  }  

  shipping_date_data = data[0]
  puts "Shipping date: #{shipping_date_data}"
  release_data.shipping_date = shipping_date_data.split[3]
  
  return release_data

end