Class: LetterAvatar::Identity
- Inherits:
-
Object
- Object
- LetterAvatar::Identity
- Defined in:
- lib/letter_avatar.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#letter ⇒ Object
Returns the value of attribute letter.
Class Method Summary collapse
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
5 6 7 |
# File 'lib/letter_avatar.rb', line 5 def color @color end |
#letter ⇒ Object
Returns the value of attribute letter.
5 6 7 |
# File 'lib/letter_avatar.rb', line 5 def letter @letter end |
Class Method Details
.from_username(username) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/letter_avatar.rb', line 7 def self.from_username(username) identity = new identity.color = LetterAvatar::COLORS[ Digest::MD5.hexdigest(username)[0...15].to_i(16) % LetterAvatar::COLORS.length ] identity.letter = username[0].upcase identity end |