Class: SeaLife::Animal

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/sea_life/animal.rb', line 3

def category
  @category
end

#distributionObject

Returns the value of attribute distribution.



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

def distribution
  @distribution
end

#habitatObject

Returns the value of attribute habitat.



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

def habitat
  @habitat
end

#habitsObject

Returns the value of attribute habits.



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

def habits
  @habits
end

#longer_descObject

Returns the value of attribute longer_desc.



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

def longer_desc
  @longer_desc
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#scientific_nameObject

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_descObject

Returns the value of attribute short_desc.



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

def short_desc
  @short_desc
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#taxonomyObject

Returns the value of attribute taxonomy.



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

def taxonomy
  @taxonomy
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.allObject



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