Class: PetriDish::Member
- Inherits:
-
Object
- Object
- PetriDish::Member
- Defined in:
- lib/petri_dish/member.rb
Instance Attribute Summary collapse
-
#genes ⇒ Object
readonly
Returns the value of attribute genes.
Instance Method Summary collapse
- #fitness ⇒ Object
-
#initialize(genes:, fitness_function:) ⇒ Member
constructor
A new instance of Member.
- #to_s ⇒ Object
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
#genes ⇒ Object (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
#fitness ⇒ Object
10 11 12 |
# File 'lib/petri_dish/member.rb', line 10 def fitness @fitness ||= @fitness_function.call(self) end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/petri_dish/member.rb', line 14 def to_s genes.join("") end |