Project

css_color

0.0
No commit activity in last 3 years
No release in over 3 years
Make sense of any css color string.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme

CSS Color

Make sense of any css color string.

The color gem is fantastic, but it is a requirement that you know what type of color you're parsing: #fff, blue, rgb(0, 0, 0)

This gem handles that requirement for you:

require "css_color"

CSSColor.parse("#fff")
#=> RGB [#ffffff]

CSSColor.parse("blue")
#=> RGB [#0000ff]

CSSColor.parse("rgb(0, 0, 0)")
#=> RGB [#000000]

CSSColor.parse("rgb(50%, 50%, 50%)")
#=> RGB [#808080]

The return type is an instance of the Color class, which has a rich feature set.

This gem aims to comply with the color grammar defined here.

RGBA, HSL and HSLA are not part of this specification. You're welcome to implement them and send a pull request.