如何在Ruby中将html颜色名称转换为RGB值?

bas*_*ibe 7 ruby gem colors

我知道有一种名为Color的宝石.我安装了它.

但对于我的生活,我无法弄清楚如何使用这个东西.

我只是想将颜色名称转换为RGB值,如果可能的话,不将整个颜色表复制到我的代码中.

我希望能够将类似redNavy转换为三个数值.

tok*_*and 11

require 'color/css'
red_code = Color::CSS["red"].html
#=> "#ff0000"
Run Code Online (Sandbox Code Playgroud)