class MixReport

Public Class Methods

new( matron, sire ) click to toggle source
# File lib/copycats/reports/mix.rb, line 5
def initialize( matron, sire )
  @matron_id   = matron.id
  @sire_id     = sire.id
  @matron_kai  = fmt_kai( matron.genes_kai )    ## pretty print in groups of four (4)
  @sire_kai    = fmt_kai( sire.genes_kai )
end

Public Instance Methods

build() click to toggle source
# File lib/copycats/reports/mix.rb, line 13
def build
  buf = "# Kitty \##{@matron_id} + \##{@sire_id}\n\n"
  buf << "genes (kai) 1: #{@matron_kai}\n"
  buf << "genes (kai) 2: #{@sire_kai}\n\n"

  buf << Genome.new( @matron_kai ).build_mix_tables( Genome.new( @sire_kai ))

  ## puts buf
  buf
end
fmt_kai( kai ) click to toggle source

helpers

todo: move to helpers module for (re)use
# File lib/copycats/reports/mix.rb, line 37
def fmt_kai( kai )
  ## format in groups of four (4) separated by space
  ##  e.g.  ccac7787fa7fafaa16467755f9ee444467667366cccceede
  ##     :  ccac 7787 fa7f afaa 1646 7755 f9ee 4444 6766 7366 cccc eede
  kai.reverse.gsub( /(.{4})/, '\1 ').reverse.strip
end
save( path ) click to toggle source

fix/todo: use “generic” report class (inherits save)!!!!!

# File lib/copycats/reports/mix.rb, line 26
def save( path )
  File.open( path, "w" ) do |f|
    f.write build
  end
end