Class: MixReport
- Inherits:
-
Object
- Object
- MixReport
- Defined in:
- lib/copycats/reports/mix.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#fmt_kai(kai) ⇒ Object
helpers todo: move to helpers module for (re)use.
-
#initialize(matron, sire) ⇒ MixReport
constructor
A new instance of MixReport.
-
#save(path) ⇒ Object
fix/todo: use “generic” report class (inherits save)!!!!!.
Constructor Details
#initialize(matron, sire) ⇒ MixReport
Returns a new instance of MixReport.
5 6 7 8 9 10 |
# 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 |
Instance Method Details
#build ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
helpers
todo: move to helpers module for (re)use
37 38 39 40 41 42 |
# 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) ⇒ Object
fix/todo: use “generic” report class (inherits save)!!!!!
26 27 28 29 30 |
# File 'lib/copycats/reports/mix.rb', line 26 def save( path ) File.open( path, "w" ) do |f| f.write build end end |