Class: Mooncats::Metadata::Design

Inherits:
Object
  • Object
show all
Defined in:
lib/mooncats/structs.rb

Overview

nested classed - why? lets you use Metadata::Design “standalone”, that is, without 5-byte id

Instance Method Summary collapse

Constructor Details

#initialize(num) ⇒ Design

0-127 design num(ber)



38
39
40
# File 'lib/mooncats/structs.rb', line 38

def initialize( num )   # 0-127 design num(ber)
  @num = num
end

Instance Method Details

#bitsObject

keep private / internal - why? why not?



44
45
46
47
48
# File 'lib/mooncats/structs.rb', line 44

def bits  ## keep private / internal - why? why not?
  ## keep 128 possible designs 0 to 127
  ##   as 7 bit string e.g. 01010111  for now - why? why not?
  @bits ||= '%08b' % @num
end

#faceObject



53
54
55
# File 'lib/mooncats/structs.rb', line 53

def face
  @face ||= FACES[ bits[2,2].to_i(2) ]
end

#facingObject



50
51
52
# File 'lib/mooncats/structs.rb', line 50

def facing
  @facing ||= FACINGS[ bits[1,1].to_i(2) ]  ## use desgin > 63 instead  - why? why not?
end

#furObject



56
57
58
# File 'lib/mooncats/structs.rb', line 56

def fur
  @fur ||= FURS[ bits[4,2].to_i(2) ]
end

#poseObject



59
60
61
# File 'lib/mooncats/structs.rb', line 59

def pose
  @poses ||= POSES[ bits[6,2].to_i(2) ]   ##  use design % 4 instead - why? why not?
end

#to_iObject



42
# File 'lib/mooncats/structs.rb', line 42

def to_i() @num; end