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.