Class: SeaLife::Category
- Inherits:
-
Object
- Object
- SeaLife::Category
- Defined in:
- lib/sea_life/category.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#animals ⇒ Object
Returns the value of attribute animals.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Category
constructor
A new instance of Category.
Constructor Details
#initialize(hash) ⇒ Category
Returns a new instance of Category.
6 7 8 9 10 |
# File 'lib/sea_life/category.rb', line 6 def initialize(hash) hash.each { |k, v| self.send("#{k}=", v) } self.class.all << self @animals = [] end |
Instance Attribute Details
#animals ⇒ Object
Returns the value of attribute animals.
2 3 4 |
# File 'lib/sea_life/category.rb', line 2 def animals @animals end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/sea_life/category.rb', line 2 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/sea_life/category.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
12 13 14 |
# File 'lib/sea_life/category.rb', line 12 def self.all @@all end |
.find_by_name(name) ⇒ Object
16 17 18 |
# File 'lib/sea_life/category.rb', line 16 def self.find_by_name(name) self.all.detect { |c| c.name == name } end |