Class: Species

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/earth/pet/species.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](name) ⇒ Object



16
17
18
# File 'lib/earth/pet/species.rb', line 16

def [](name)
  find_by_name name.to_s
end

Instance Method Details

#cat?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/earth/pet/species.rb', line 35

def cat?
  eql? self.class[:cat]
end

#diet_sizeObject



21
22
23
24
# File 'lib/earth/pet/species.rb', line 21

def diet_size
  return unless weight and marginal_dietary_requirement and fixed_dietary_requirement
  weight * marginal_dietary_requirement + fixed_dietary_requirement
end

#to_sObject



31
32
33
# File 'lib/earth/pet/species.rb', line 31

def to_s
  name
end

#weighted_diet_sizeObject



26
27
28
29
# File 'lib/earth/pet/species.rb', line 26

def weighted_diet_size
  return unless _diet_size = diet_size and _population = population
  _diet_size * _population
end