Class: Genetica::ChromosomeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/genetica/chromosome_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChromosomeBuilder

Returns a new instance of ChromosomeBuilder.



5
6
7
# File 'lib/genetica/chromosome_builder.rb', line 5

def initialize
  set_default_chromosome_attributes
end

Instance Attribute Details

#allelesObject

Returns the value of attribute alleles.



3
4
5
# File 'lib/genetica/chromosome_builder.rb', line 3

def alleles
  @alleles
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/genetica/chromosome_builder.rb', line 3

def length
  @length
end

Instance Method Details

#chromosomeObject



9
10
11
12
13
# File 'lib/genetica/chromosome_builder.rb', line 9

def chromosome
  Chromosome.new.tap do |chromosome|
    length.times { chromosome << alleles.sample }
  end
end