Class: Faker::Color
- Inherits:
-
Base
show all
- Defined in:
- lib/faker/default/color.rb
Constant Summary
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.color_name ⇒ Object
10
11
12
|
# File 'lib/faker/default/color.rb', line 10
def color_name
fetch('color.name')
end
|
.hex_color ⇒ Object
6
7
8
|
# File 'lib/faker/default/color.rb', line 6
def hex_color
format('#%06x', (rand * 0xffffff))
end
|
.hsl_color ⇒ Object
returns [hue, saturation, lightness]
23
24
25
|
# File 'lib/faker/default/color.rb', line 23
def hsl_color
[sample((0..360).to_a), rand.round(2), rand.round(2)]
end
|
.hsla_color ⇒ Object
27
28
29
|
# File 'lib/faker/default/color.rb', line 27
def hsla_color
hsl_color << rand.round(1)
end
|
.rgb_color ⇒ Object
18
19
20
|
# File 'lib/faker/default/color.rb', line 18
def rgb_color
Array.new(3) { single_rgb_color }
end
|
.single_rgb_color ⇒ Object
14
15
16
|
# File 'lib/faker/default/color.rb', line 14
def single_rgb_color
sample((0..255).to_a)
end
|