Class: Mooncats::Metadata::Design
- Inherits:
-
Object
- Object
- Mooncats::Metadata::Design
- 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
-
#bits ⇒ Object
keep private / internal - why? why not?.
-
#face ⇒ Object
(also: #expression)
face (expression).
- #facing ⇒ Object
-
#fur ⇒ Object
fur (pattern) - add pattern alias - why? why not?.
-
#initialize(num) ⇒ Design
constructor
0-127 design num(ber).
- #pose ⇒ Object
- #to_i ⇒ Object
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
#bits ⇒ Object
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 |
#face ⇒ Object 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 |
#facing ⇒ Object
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 |
#fur ⇒ Object
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 |
#pose ⇒ Object
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_i ⇒ Object
59 |
# File 'lib/mooncats/structs.rb', line 59 def to_i() @num; end |