Method: Genome#initialize
- Defined in:
- lib/kittyverse/genome.rb
#initialize(arg) ⇒ Genome
Returns a new instance of Genome.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kittyverse/genome.rb', line 5 def initialize( arg ) if arg.is_a? Integer ## use Integer (Fixnum+Bignum??) - why? why not? num = arg kai = Kai.encode( num ) else if arg.downcase.start_with?( '0x' ) ## assume hexstring( base16 ) kai = Kai.encode( arg.to_i(16) ) else # else assume string in kai/base32 format kai = arg kai = kai.gsub( ' ', '' ) ## allow spaces (strip/remove) end end ## puts "Genome.initialize #{kai}" @kai = kai ## note: store/save kai without any spaces ("compact" format) @genes = build_genes( kai ) ## array of (sliced) genes (block of four genes) end |