Class: ColorPicker::Color
- Inherits:
-
Object
- Object
- ColorPicker::Color
- Defined in:
- lib/color_picker/color.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#palette ⇒ Object
Returns the value of attribute palette.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize ⇒ Color
constructor
A new instance of Color.
- #palette_type(type) ⇒ Object
Constructor Details
#initialize ⇒ Color
Returns a new instance of Color.
6 7 8 9 10 |
# File 'lib/color_picker/color.rb', line 6 def initialize @palette = Palette.new @code = "" generate end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/color_picker/color.rb', line 4 def code @code end |
#palette ⇒ Object
Returns the value of attribute palette.
3 4 5 |
# File 'lib/color_picker/color.rb', line 3 def palette @palette end |
Instance Method Details
#generate ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/color_picker/color.rb', line 16 def generate @code = "" @palette.range.each_with_index do |range, index| @code += range.to_a[rand(range.size)].to_s(16).rjust(2, '0') end @code end |
#palette_type(type) ⇒ Object
24 25 26 |
# File 'lib/color_picker/color.rb', line 24 def palette_type(type) palette.type = type end |