Skip to content

Commit b5ecfde

Browse files
committed
another colos palette option fix
1 parent b057e52 commit b5ecfde

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/letter_avatar/colors.rb

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@ module LetterAvatar
22
module Colors
33

44
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)
515
char = username[0].upcase
616

717
if /[A-Z]/.match(char)
818
# 65 is 'A' ord
919
idx = char.ord - 65
10-
COLORS[idx]
20+
google[idx]
1121
elsif /[\d]/.match(char)
12-
COLORS[char.to_i]
22+
google[char.to_i]
1323
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]
1525
end
1626
end
1727

18-
def self.colors
19-
public_send(LetterAvatar.colors_palette) rescue google
20-
end
21-
2228

2329
# Colors form Google Inbox
2430
# https://inbox.google.com

lib/letter_avatar/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module LetterAvatar
2-
VERSION = "0.1.2"
2+
VERSION = "0.1.3"
33
end

0 commit comments

Comments
 (0)