Class: Dumper::Profiles::Teca

Inherits:
Profile
  • Object
show all
Defined in:
lib/dumper/profiles/teca.rb

Instance Method Summary collapse

Instance Method Details

#dump(url, path, from, to) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dumper/profiles/teca.rb', line 24

def dump(url, path, from, to)
  from -= 1
  to   -= 1 if to >= 1
  url   = url.split('index').first

  [].tap { |urls|
    Nokogiri::HTML(open(url)).xpath('//a/@href').each { |u|
      urls << u if u.to_s =~ /.\.(png|bmp|jpeg|jpg|gif|tiff)$/i
    }
  }.reverse[from..to].each { |p|
    @pool.process {
      Dumper.get path, "#{url}/#{p}"
    }
  }
end