Class: GenomeTables
- Inherits:
-
Object
- Object
- GenomeTables
- Defined in:
- lib/kittyverse/genome.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#fmt_trait(trait) ⇒ Object
helpers.
-
#initialize(genome) ⇒ GenomeTables
constructor
A new instance of GenomeTables.
Constructor Details
#initialize(genome) ⇒ GenomeTables
Returns a new instance of GenomeTables.
185 186 187 |
# File 'lib/kittyverse/genome.rb', line 185 def initialize( genome ) @genome = genome end |
Instance Method Details
#build ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/kittyverse/genome.rb', line 189 def build pos = 0 buf = "" buf << "Genes (256-Bit Integer Number):\n" buf << "- Base 10 (Decimal): #{@genome.num}\n" buf << "- Base 2 (Binary): #{@genome.binary}\n" buf << "- Base 2⁵ = 32\n" buf << " - (Kai): #{@genome.kai}\n" buf << " - (Codes): #{@genome.codes}\n" buf << "\n\n" @genome.each do |slice| tt = slice.type buf << "#{tt.name} (#{tt.code}) - Genes #{tt.genes}\n\n" ### ## fix/todo: add stars for purity? ## **** - all traits the same ## *** - two same pairs of traits ## ** - one pair of same traits buf << "|Gene |Binary |Kai |Code | Name | |\n" buf << "|------|---------|-----|-----|----------|---|\n" buf << "| #{pos} | #{slice.d.binary} | #{slice.d.kai} | #{slice.d.code} |**#{fmt_trait(slice.d)}** | d |\n"; pos+=1 buf << "| #{pos} | #{slice.r1.binary} | #{slice.r1.kai} | #{slice.r1.code} |#{fmt_trait(slice.r1)} | r1 |\n"; pos+=1 buf << "| #{pos} | #{slice.r2.binary} | #{slice.r2.kai} | #{slice.r2.code} |#{fmt_trait(slice.r2)} | r2 |\n"; pos+=1 buf << "| #{pos} | #{slice.r3.binary} | #{slice.r3.kai} | #{slice.r3.code} |#{fmt_trait(slice.r3)} | r3 |\n"; pos+=1 buf << "\n" if tt.key == :body ## add legend for first entry buf << "d = dominant, r1 = 1st order recessive, r2 = 2nd order recessive, r3 = 3rd order recessive\n\n" end end buf end |
#fmt_trait(trait) ⇒ Object
helpers
230 231 232 233 234 235 |
# File 'lib/kittyverse/genome.rb', line 230 def fmt_trait( trait ) buf = "" buf << (trait.name || '∅') buf << " #{trait.tier_roman}" if trait.tier > 0 buf end |