Sha256: 4c2930ca1686272a681455bc1968f50bd144d09e54af1207719b102b20052c8f
Contents?: true
Size: 580 Bytes
Versions: 19
Compression:
Stored size: 580 Bytes
Contents
# frozen_string_literal: true module Faker class Color < Base class << self def hex_color format('#%06x', (rand * 0xffffff)) end def color_name fetch('color.name') end def single_rgb_color sample((0..255).to_a) end def rgb_color Array.new(3) { single_rgb_color } end # returns [hue, saturation, lightness] def hsl_color [sample((0..360).to_a), rand.round(2), rand.round(2)] end def hsla_color hsl_color << rand.round(1) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems