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



18
19
20
# File 'lib/earth/pet/species.rb', line 18

def [](name)
  find_by_name name.to_s
end

Instance Method Details

#cat?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/earth/pet/species.rb', line 37

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

#diet_sizeObject



23
24
25
26
# File 'lib/earth/pet/species.rb', line 23

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

#to_sObject



33
34
35
# File 'lib/earth/pet/species.rb', line 33

def to_s
  name
end

#weighted_diet_sizeObject



28
29
30
31
# File 'lib/earth/pet/species.rb', line 28

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