Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed length check from AwesomePrint::Color#hex to a regex (checks …

…for hex pattern too). lookup_by_n looksup 255 if an invalid number is specified.
  • Loading branch information...
commit b97a13920f1ac84bf9aa333ca73d6d7b856630f5 1 parent 1d243af
@basicxman authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/awesome_print/colors.rb
View
3  lib/awesome_print/colors.rb 100644 → 100755
@@ -11,7 +11,7 @@ def self.rgb(*args)
end
def self.hex(c)
- if c.length != 6 and c.length != 7
+ if (c =~ /^#?[0-9A-Fa-f]{6}$/).nil?
c
else
c = "#" + c if c.length == 6
@@ -34,6 +34,7 @@ def self.lookup_by_hex(c)
end
def self.lookup_by_num(n)
+ n = 255 if n < 16 or n > 255
colors[n - 16][2]
end
Please sign in to comment.
Something went wrong with that request. Please try again.