Class: Polychromasia::ColorPicker

Inherits:
Object
  • Object
show all
Defined in:
lib/polychromasia.rb

Instance Method Summary collapse

Instance Method Details

#random_colors_to_hexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/polychromasia.rb', line 5

def random_colors_to_hex
	color_values = Hash.new
	color_inputs = ['red', 'green', 'blue']

	color_inputs.each do |i|
		v = rand(255)
		color_values[i.to_s] = v
	end

	@hex_color = ""
	color = color_values.values

	color.each do |component|
		hex = component.to_s(16)
		if component < 10
			@hex_color << "0#{hex}"
		else
			@hex_color << hex
		end
	end

	puts @hex_color
	return @hex_color
end