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)



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

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

Instance Method Details

#bitsObject

keep private / internal - why? why not?



61
62
63
64
65
# File 'lib/mooncats/structs.rb', line 61

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 Also known as: expression

face (expression)



70
71
72
# File 'lib/mooncats/structs.rb', line 70

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

#facingObject



67
68
69
# File 'lib/mooncats/structs.rb', line 67

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

#furObject

fur (pattern) - add pattern alias - why? why not?



75
76
77
# File 'lib/mooncats/structs.rb', line 75

def fur    ## fur (pattern)   - add pattern alias - why? why not?
  @fur ||= FURS[ bits[4,2].to_i(2) ]
end

#poseObject



79
80
81
# File 'lib/mooncats/structs.rb', line 79

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

#to_iObject



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

def to_i() @num; end