Class: BrandEins::Downloader::ArchiveSite
- Inherits:
-
Object
- Object
- BrandEins::Downloader::ArchiveSite
- Defined in:
- lib/brandeins.rb
Defined Under Namespace
Classes: ArchiveMagazine
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
Instance Method Summary collapse
- #get_magazine_links_by_year(year = 2000) ⇒ Object
-
#initialize(base_url, html = false) ⇒ ArchiveSite
constructor
A new instance of ArchiveSite.
- #magazine_pdf_links(url) ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(base_url, html = false) ⇒ ArchiveSite
Returns a new instance of ArchiveSite.
155 156 157 158 159 160 161 |
# File 'lib/brandeins.rb', line 155 def initialize(base_url, html = false) @base_url = base_url @archive_url = @base_url + "/archiv.html" if html @doc = Nokogiri::HTML(html) end end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
153 154 155 |
# File 'lib/brandeins.rb', line 153 def doc @doc end |
Instance Method Details
#get_magazine_links_by_year(year = 2000) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/brandeins.rb', line 168 def get_magazine_links_by_year(year = 2000) setup puts "Loading Magazine from year #{year}" = @doc.css(".jahrgang-#{year} ul li") magazine_links = Array.new .each_with_index do |node, index| if node['id'].nil? then link = node.css('a') if link[0].nil? then next end href = link[0]['href'] magazine_links << @base_url + '/' + href end end magazine_links end |
#magazine_pdf_links(url) ⇒ Object
186 187 188 189 |
# File 'lib/brandeins.rb', line 186 def magazine_pdf_links(url) magazine = ArchiveMagazine.new(url, @base_url) magazine.get_magazine_pdf_links end |
#setup ⇒ Object
163 164 165 166 |
# File 'lib/brandeins.rb', line 163 def setup return if defined?(@doc) != nil @doc = Nokogiri::HTML(open(@archive_url)) end |