Class: T::Identicon
- Inherits:
-
Object
- Object
- T::Identicon
- Defined in:
- lib/t/identicon.rb
Instance Attribute Summary collapse
-
#bits ⇒ Object
Six-bit number (0-63).
-
#color ⇒ Object
Eight-bit number (0-255).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(number) ⇒ Identicon
constructor
A new instance of Identicon.
- #lines ⇒ Object
Constructor Details
#initialize(number) ⇒ Identicon
Returns a new instance of Identicon.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/t/identicon.rb', line 9 def initialize(number) # Bottom six bits @bits = number & 0x3f # Next highest eight bits @fcolor = (number >> 6) & 0xff # Next highest eight bits @bcolor = (number >> 14) & 0xff end |
Instance Attribute Details
#bits ⇒ Object
Six-bit number (0-63)
4 5 6 |
# File 'lib/t/identicon.rb', line 4 def bits @bits end |
#color ⇒ Object
Eight-bit number (0-255)
7 8 9 |
# File 'lib/t/identicon.rb', line 7 def color @color end |
Class Method Details
Instance Method Details
#lines ⇒ Object
20 21 22 23 24 |
# File 'lib/t/identicon.rb', line 20 def lines ["#{bg @bits[0]} #{bg @bits[1]} #{bg @bits[0]} #{reset}", "#{bg @bits[2]} #{bg @bits[3]} #{bg @bits[2]} #{reset}", "#{bg @bits[4]} #{bg @bits[5]} #{bg @bits[4]} #{reset}"] end |