Class: Shark::SharkRays
- Inherits:
-
Object
- Object
- Shark::SharkRays
- Defined in:
- lib/shark/sharkrays.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#distribution ⇒ Object
Returns the value of attribute distribution.
-
#feeding ⇒ Object
Returns the value of attribute feeding.
-
#habitat ⇒ Object
Returns the value of attribute habitat.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scientific_name ⇒ Object
Returns the value of attribute scientific_name.
-
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name = nil, url = nil) ⇒ SharkRays
constructor
A new instance of SharkRays.
Constructor Details
#initialize(name = nil, url = nil) ⇒ SharkRays
13 14 15 16 17 |
# File 'lib/shark/sharkrays.rb', line 13 def initialize(name = nil, url = nil) @name = name @url = "https://oceana.org" +url @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def description @description end |
#distribution ⇒ Object
Returns the value of attribute distribution.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def distribution @distribution end |
#feeding ⇒ Object
Returns the value of attribute feeding.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def feeding @feeding end |
#habitat ⇒ Object
Returns the value of attribute habitat.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def habitat @habitat end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def name @name end |
#scientific_name ⇒ Object
Returns the value of attribute scientific_name.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def scientific_name @scientific_name end |
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def taxonomy @taxonomy end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/shark/sharkrays.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/shark/sharkrays.rb', line 19 def self.all @@all end |
.find(id) ⇒ Object
23 24 25 |
# File 'lib/shark/sharkrays.rb', line 23 def self.find(id) self.all[id-1] end |
.new_from_shark_index(shark) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/shark/sharkrays.rb', line 6 def self.new_from_shark_index(shark) self.new( shark.css("h1").text, shark.css("a").attr("href").value ) end |
Instance Method Details
#doc ⇒ Object
27 28 29 |
# File 'lib/shark/sharkrays.rb', line 27 def doc @doc = Nokogiri::HTML(open(self.url)) end |