mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
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
1 changed files with 14 additions and 0 deletions
14
lib/sass/constant/color.rb
Normal file
14
lib/sass/constant/color.rb
Normal 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
|
Loading…
Add table
Reference in a new issue