Class: Specie
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Specie
- Defined in:
- app/models/specie.rb
Overview
This class describes a specie. The upper class of Mob.
Instance Method Summary (collapse)
-
- (Integer) mobs_female_num
Return the number of female mobs belong to this specie.
-
- (Integer) mobs_male_num
Return the number of male mobs belong to this specie.
-
- (Integer) mobs_num
Return the number of mobs belong to this specie.
Instance Method Details
- (Integer) mobs_female_num
Return the number of female mobs belong to this specie.
28 29 30 31 32 33 34 |
# File 'app/models/specie.rb', line 28 def mobs_female_num mobs_female_num = 0 mobs.each do |mob| mobs_female_num += 1 if mob.female? or mob.asexual? end return mobs_female_num end |
- (Integer) mobs_male_num
Return the number of male mobs belong to this specie.
18 19 20 21 22 23 24 |
# File 'app/models/specie.rb', line 18 def mobs_male_num mobs_male_num = 0 mobs.each do |mob| mobs_male_num += 1 if not mob.female? and not mob.asexual? end return mobs_male_num end |
- (Integer) mobs_num
Return the number of mobs belong to this specie.
11 12 13 14 |
# File 'app/models/specie.rb', line 11 def mobs_num return 0 if mobs.blank? return mobs.length end |