Class: SeaLife::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/sea_life/category.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#animalsObject

Returns the value of attribute animals.



2
3
4
# File 'lib/sea_life/category.rb', line 2

def animals
  @animals
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/sea_life/category.rb', line 2

def name
  @name
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/sea_life/category.rb', line 2

def url
  @url
end

Class Method Details

.allObject



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