Class: Zyps::PopulationLimit
- Inherits:
-
EnvironmentalFactor
- Object
- EnvironmentalFactor
- Zyps::PopulationLimit
- Defined in:
- lib/zyps/environmental_factors.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Maximum allowed population.
Instance Method Summary collapse
-
#act(environment) ⇒ Object
Remove target if there are too many objects in environment.
-
#initialize(count) ⇒ PopulationLimit
constructor
A new instance of PopulationLimit.
Constructor Details
#initialize(count) ⇒ PopulationLimit
Returns a new instance of PopulationLimit.
218 219 220 |
# File 'lib/zyps/environmental_factors.rb', line 218 def initialize(count) self.count = count end |
Instance Attribute Details
#count ⇒ Object
Maximum allowed population.
216 217 218 |
# File 'lib/zyps/environmental_factors.rb', line 216 def count @count end |
Instance Method Details
#act(environment) ⇒ Object
Remove target if there are too many objects in environment.
223 224 225 226 |
# File 'lib/zyps/environmental_factors.rb', line 223 def act(environment) excess = environment.objects.length - @count environment.objects.slice!(0, excess) if excess > 0 end |