instance method Number#toColorPart

View source on GitHub →

Number#toColorPart() → String

Produces a 2-digit hexadecimal representation of the number (which is therefore assumed to be in the [0..255] range, inclusive). Useful for composing CSS color strings.

Example
10.toColorPart()
// -> "0a"