2012-11-21 22:55:53 +01:00
|
|
|
module Mutant
|
|
|
|
class Killer
|
|
|
|
|
2012-11-22 01:42:10 +01:00
|
|
|
class Forked < self
|
2012-12-04 19:38:58 +01:00
|
|
|
def initialize(killer, strategy, mutation)
|
2012-11-22 01:42:10 +01:00
|
|
|
@killer = killer
|
2012-12-04 19:38:58 +01:00
|
|
|
super(strategy, mutation)
|
2012-11-22 01:42:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def type
|
|
|
|
@killer.type
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
fork do
|
2012-12-04 19:38:58 +01:00
|
|
|
@killer.new(strategy, mutation)
|
2012-11-22 01:42:10 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
status = Process.wait2.last
|
|
|
|
status.exitstatus.zero?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Forking < self
|
|
|
|
include Equalizer.new(:killer)
|
|
|
|
|
|
|
|
attr_reader :killer
|
|
|
|
|
2012-12-04 19:38:58 +01:00
|
|
|
def initialize(killer)
|
2012-11-22 01:42:10 +01:00
|
|
|
@killer = killer
|
|
|
|
end
|
|
|
|
|
2012-12-04 19:38:58 +01:00
|
|
|
def new(strategy, mutation)
|
|
|
|
Forked.new(killer, strategy, mutation)
|
2012-11-22 01:42:10 +01:00
|
|
|
end
|
2012-12-04 19:38:58 +01:00
|
|
|
|
2012-11-22 01:42:10 +01:00
|
|
|
end
|
|
|
|
|
2012-11-21 22:55:53 +01:00
|
|
|
end
|
|
|
|
end
|