Convert CSS RGB value to HEX value
A simple function to convert CSS return value of capybara's
evaluate_script
call to $('.class).css('value')
to HEX value:
def rgb_to_hex(value)
%Q{
##{
value.match(/[\d,\s]+/)[0].split(',').map(&:strip).map { |value|
value.to_i.to_s(16).rjust(2, '0')
}.join('')
}
}.strip
end
Written by Filip Tepper
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#