Class: PetriDish::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/petri_dish/member.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(genes:, fitness_function:) ⇒ Member

Returns a new instance of Member.



5
6
7
8
# File 'lib/petri_dish/member.rb', line 5

def initialize(genes:, fitness_function:)
  @fitness_function = fitness_function
  @genes = genes
end

Instance Attribute Details

#genesObject (readonly)

Returns the value of attribute genes.



3
4
5
# File 'lib/petri_dish/member.rb', line 3

def genes
  @genes
end

Instance Method Details

#fitnessObject



10
11
12
# File 'lib/petri_dish/member.rb', line 10

def fitness
  @fitness ||= @fitness_function.call(self)
end

#to_sObject



14
15
16
# File 'lib/petri_dish/member.rb', line 14

def to_s
  genes.join("")
end