Class: Faker::Color
Constant Summary
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale
Class Method Details
.color_name ⇒ Object
8
9
10
|
# File 'lib/faker/color.rb', line 8
def color_name
fetch('color.name')
end
|
.hex_color ⇒ Object
4
5
6
|
# File 'lib/faker/color.rb', line 4
def hex_color
'#%06x' % (rand * 0xffffff)
end
|
.hsl_color ⇒ Object
returns [hue, saturation, lightness]
21
22
23
|
# File 'lib/faker/color.rb', line 21
def hsl_color
[sample((0..360).to_a), rand.round(2), rand.round(2)]
end
|
.hsla_color ⇒ Object
25
26
27
|
# File 'lib/faker/color.rb', line 25
def hsla_color
hsl_color << rand.round(1)
end
|
.rgb_color ⇒ Object
16
17
18
|
# File 'lib/faker/color.rb', line 16
def rgb_color
3.times.collect { single_rgb_color }
end
|
.single_rgb_color ⇒ Object
12
13
14
|
# File 'lib/faker/color.rb', line 12
def single_rgb_color
sample((0..255).to_a)
end
|