Class: SharksAhead::SharkExtinct

Inherits:
Object
  • Object
show all
Defined in:
lib/sharks_ahead/shark-extinct.rb

Class Method Summary collapse

Class Method Details

.get_extinct_sharksObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sharks_ahead/shark-extinct.rb', line 3

def self.get_extinct_sharks
  extinct_sharks = []
  url = [
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/cretoxyrhina.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/Edestus.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/helicoprion.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/hybodus.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/otodus.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/ptychodus.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/squalicorax.htm',
    'http://dinosaurs.about.com/od/tetrapodsandamphibians/p/stethacanthus.htm',
    ]
  url.each do |u|
    doc = Nokogiri::HTML(open(u))
    name = doc.search('h1').text
    description = doc.search('div.col-push-2.col-push-tablet-1.content-responsive p').text.tr("\n", " ")
    extinct_sharks << {name: name, description: description}
  end
  extinct_sharks
end