Really adding Color literal.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@254 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-12-23 22:31:32 +00:00
parent 808dcec05f
commit 16ebd26a04
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
module Sass::Constant
class Color
REGEXP = /\##{"([0-9a-f]{1,2})" * 3}/
def initialize(value)
@red, @green, @blue = value.scan(REGEXP)[0].map { |num| num.ljust(2, 'f').to_i(16) }
end
def to_s
red, green, blue = [@red, @green, @blue].map { |num| num.to_s(16).rjust(2, '0') }
"##{red}#{green}#{blue}"
end
end
end