Class: BrandEins::Downloader

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

Defined Under Namespace

Classes: ArchiveSite, PDFDownloader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Downloader

Returns a new instance of Downloader.



48
49
50
51
52
53
54
# File 'lib/brandeins.rb', line 48

def initialize(path)
  @url     = 'http://www.brandeins.de'
  @archive = false
  @dl_dir  = path
  @tmp_dir = path + '/tmp'
  create_tmp_dirs
end

Instance Attribute Details

#archiveObject (readonly)

Returns the value of attribute archive.



46
47
48
# File 'lib/brandeins.rb', line 46

def archive
  @archive
end

Instance Method Details

#get_magazine(year = 2000, volume = 1) ⇒ Object



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

def get_magazine(year = 2000, volume = 1)
  setup
  puts "Parsing Volume #{volume} of #{year}"
  target_pdf = get_target_pdf(year, volume)

  magazine_links = @archive.get_magazine_links_by_year(year)
  target_magazine_link = magazine_links[volume-1]

  get_magazine_by_link(target_magazine_link, target_pdf)
end

#get_magazines_of_year(year = 2000) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/brandeins.rb', line 60

def get_magazines_of_year(year = 2000)
  setup
  puts "Getting all brand eins magazines of a #{year}. This could take a while..."
  magazine_links_per_year = @archive.get_magazine_links_by_year(year)
  magazine_links_per_year.each_with_index do |magazine_link, volume|
    puts "Parsing Volume #{volume} of #{year}"
    target_pdf = get_target_pdf(year, volume)
    get_magazine_by_link(magazine_link, target_pdf)
  end
end

#setupObject



56
57
58
# File 'lib/brandeins.rb', line 56

def setup
  @archive = ArchiveSite.new @url
end