class Gene::Slice
todo/check:
find a better name for Slice(incl.4 genes) e.g. GeneFour, Gene4, GeneGroup, GeneSlice,TraitGenes,... - why? why not?
Attributes
d[R]
d0[R]
h1[R]
h2[R]
h3[R]
p[R]
r1[R]
r2[R]
r3[R]
type[R]
Public Class Methods
new( type, d, r1, r2, r3 )
click to toggle source
# File lib/kittyverse/gene.rb, line 26 def initialize( type, d, r1, r2, r3 ) @type = TraitType[type] ## lookup trait type by key (e.g. :body, :pattern, etc.) @d = @type[d] ## lookup trait (from trait type) by kai code (e.g. "1", "a", etc.) @r1 = @type[r1] @r2 = @type[r2] @r3 = @type[r3] end
Public Instance Methods
[](index)
click to toggle source
# File lib/kittyverse/gene.rb, line 34 def [](index) case index when 0 then @d when 1 then @r1 when 2 then @r2 when 3 then @r3 else nil ## return nil for unknown index for now (raise except - why? why not?) end end
purebred?()
click to toggle source
# File lib/kittyverse/gene.rb, line 44 def purebred?() @d == @r1 && @d == @r2 && @d == @r3; end
Also aliased as: pure?
to_kai()
click to toggle source
# File lib/kittyverse/gene.rb, line 48 def to_kai @r3.kai + @r2.kai + @r1.kai + @d.kai end