# Color gem

**URL:** <https://www.ruby-forum.com/t/color-gem/112978>\
**Category:** Rails\
**Created:** [August 25, 2007, 8:45am UTC](https://www.ruby-forum.com/t/color-gem/112978 "2007-08-25T08:45:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mariko](https://www.ruby-forum.com/u/mariko)\
**Post date:** [August 25, 2007, 8:45am UTC](https://www.ruby-forum.com/t/color-gem/112978/1 "2007-08-25T08:45:58Z")

</div>

I’m using the ruby gem “Color” and I’m having some troubles with to\_hex.

I’ve installed the gem, and when I try and run the test program I get  
this error:

> > red = Color.new(‘ff0000’)  
> > =\> #\<Color:0x3685990 @saturation=1.0, @hue=0.0, @lightness=0.5\>
> 
> > yellow = Color.new(‘ffff00’)  
> > =\> #\<Color:0x367e5a0 @saturation=1.0, @hue=0.166666666666667,  
> > @lightness=0.5\>
> 
> > orange = red.mix\_with yellow, 0.5  
> > =\> #\<Color:0x3675c34 @saturation=0.503875968992248,  
> > @hue=0.0820512820512821, @lightness=0.252941176470588\>
> 
> > orange.to\_hex  
> > NoMethodError: You have a nil object when you didn’t expect it!  
> > You might have expected an instance of Array.  
> > The error occurred while evaluating nil.collect  
> > from  
> > /Applications/Locomotive2/Bundles/rmagickRailsMar2007\_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/color-0.1.0/lib/color.rb:91:in  
> > `rgb_to_rgbhex' from /Applications/Locomotive2/Bundles/rmagickRailsMar2007_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/color-0.1.0/lib/color.rb:81:in`to\_hex’  
> > from (irb):15

Does anyone know what’s going on here? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mariko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mariko](https://www.ruby-forum.com/u/mariko)\
**Post date:** [August 25, 2007, 12:57pm UTC](https://www.ruby-forum.com/t/color-gem/112978/2 "2007-08-25T12:57:00Z")

</div>

On 8/25/07, Mariko C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m using the ruby gem “Color” and I’m having some troubles with to\_hex.
> 
> I’ve installed the gem, and when I try and run the test program I get  
> this error:

I recommend holding off on the use of this particular gem; use  
color-tools instead, or use Stefan’s color gem on the butler project.

There are three colour manipulation projects that are being pulled  
together in one way or another; the Color project and color-tools have  
already been merged, but there’s been a lack of maintainer time to  
release an updated version.

## -austin

Austin Z. \* removed\_email\_address@domain.invalid \* [http://www.halostatue.ca/](http://www.halostatue.ca/)  
\* removed\_email\_address@domain.invalid \* [You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/feed/)  
\* removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![mariko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mariko](https://www.ruby-forum.com/u/mariko)\
**Post date:** [August 26, 2007, 12:09am UTC](https://www.ruby-forum.com/t/color-gem/112978/3 "2007-08-26T00:09:57Z")

</div>

I’ll look into those. Thanks for the response.
