Commit b5ecfde 1 parent b057e52 commit b5ecfde Copy full SHA for b5ecfde
File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,29 @@ module LetterAvatar
2
2
module Colors
3
3
4
4
def self . for ( username )
5
+ public_send ( "with_#{ LetterAvatar . colors_palette } " , username ) rescue with_google ( username )
6
+ end
7
+
8
+ def self . with_iwanthue ( username )
9
+ iwanthue [
10
+ Digest ::MD5 . hexdigest ( username ) [ 0 ...15 ] . to_i ( 16 ) % iwanthue . length
11
+ ]
12
+ end
13
+
14
+ def self . with_google ( username )
5
15
char = username [ 0 ] . upcase
6
16
7
17
if /[A-Z]/ . match ( char )
8
18
# 65 is 'A' ord
9
19
idx = char . ord - 65
10
- COLORS [ idx ]
20
+ google [ idx ]
11
21
elsif /[\d ]/ . match ( char )
12
- COLORS [ char . to_i ]
22
+ google [ char . to_i ]
13
23
else
14
- COLORS [ Digest ::MD5 . hexdigest ( username ) [ 0 ...15 ] . to_i ( 16 ) % COLORS . length ]
24
+ google [ Digest ::MD5 . hexdigest ( username ) [ 0 ...15 ] . to_i ( 16 ) % google . length ]
15
25
end
16
26
end
17
27
18
- def self . colors
19
- public_send ( LetterAvatar . colors_palette ) rescue google
20
- end
21
-
22
28
23
29
# Colors form Google Inbox
24
30
# https://inbox.google.com
Original file line number Diff line number Diff line change 1
1
module LetterAvatar
2
- VERSION = "0.1.2 "
2
+ VERSION = "0.1.3 "
3
3
end
You can’t perform that action at this time.
0 commit comments