Class: SeaLife::Animal
- Inherits:
-
Object
- Object
- SeaLife::Animal
- Defined in:
- lib/sea_life/animal.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#distribution ⇒ Object
Returns the value of attribute distribution.
-
#habitat ⇒ Object
Returns the value of attribute habitat.
-
#habits ⇒ Object
Returns the value of attribute habits.
-
#longer_desc ⇒ Object
Returns the value of attribute longer_desc.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scientific_name ⇒ Object
Returns the value of attribute scientific_name.
-
#short_desc ⇒ Object
Returns the value of attribute short_desc.
-
#status ⇒ Object
Returns the value of attribute status.
-
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_info(info) ⇒ Object
-
#initialize(info) ⇒ Animal
constructor
A new instance of Animal.
Constructor Details
#initialize(info) ⇒ Animal
Returns a new instance of Animal.
6 7 8 9 |
# File 'lib/sea_life/animal.rb', line 6 def initialize(info) add_info(info) @@all << self end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/sea_life/animal.rb', line 3 def category @category end |
#distribution ⇒ Object
Returns the value of attribute distribution.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def distribution @distribution end |
#habitat ⇒ Object
Returns the value of attribute habitat.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def habitat @habitat end |
#habits ⇒ Object
Returns the value of attribute habits.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def habits @habits end |
#longer_desc ⇒ Object
Returns the value of attribute longer_desc.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def longer_desc @longer_desc end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def name @name end |
#scientific_name ⇒ Object
Returns the value of attribute scientific_name.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def scientific_name @scientific_name end |
#short_desc ⇒ Object
Returns the value of attribute short_desc.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def short_desc @short_desc end |
#status ⇒ Object
Returns the value of attribute status.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def status @status end |
#taxonomy ⇒ Object
Returns the value of attribute taxonomy.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def taxonomy @taxonomy end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/sea_life/animal.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/sea_life/animal.rb', line 20 def self.all @@all end |
.find_by_name(name) ⇒ Object
24 25 26 |
# File 'lib/sea_life/animal.rb', line 24 def self.find_by_name(name) self.all.detect { |animal| animal.name == name } end |
Instance Method Details
#add_info(info) ⇒ Object
16 17 18 |
# File 'lib/sea_life/animal.rb', line 16 def add_info(info) info.each { |k, v| self.send("#{k}=", v) } end |