Really adding Color literal.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@254 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
808dcec05f
commit
16ebd26a04
|
@ -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
|
Loading…
Reference in New Issue