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
- #facing ⇒ Object
- #fur ⇒ Object
-
#initialize(num) ⇒ Design
constructor
0-127 design num(ber).
- #pose ⇒ Object
- #to_i ⇒ Object
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
#bits ⇒ Object
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 |
#face ⇒ Object
53 54 55 |
# File 'lib/mooncats/structs.rb', line 53 def face @face ||= FACES[ bits[2,2].to_i(2) ] end |
#facing ⇒ Object
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 |
#fur ⇒ Object
56 57 58 |
# File 'lib/mooncats/structs.rb', line 56 def fur @fur ||= FURS[ bits[4,2].to_i(2) ] end |
#pose ⇒ Object
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_i ⇒ Object
42 |
# File 'lib/mooncats/structs.rb', line 42 def to_i() @num; end |