Does:
In Gruff (0.2.9), when a nil value for @maximum_value is passed in, Rails will generate the following error:
comparison of Fixnum with nil failed
at
/var/lib/gems/1.8/gems/gruff-0.2.9/lib/gruff/base.rb:901:in `larger_than_max?'
A trace shows the larger_than_max? method does no checking for nil of method variable @maximum_value prior to a fixnum
operator compare (in this case, > or greater_than):
# Overridden by subclasses such as stacked bar.
def larger_than_max?(data_point, index=0) # :nodoc:
data_point > @maximum_value
end
Should:
Checking for a nil condition on the method variable will resolve the problem:
# Overridden by subclasses such as stacked bar.
def larger_than_max?(data_point, index=0) # :nodoc:
data_point > (@maximum_value.nil? ? 0 : @maximum_value)
end
However, given the comment for this method, I suspect that other classes (e.g. stacked bar) may exhibit the same failure
case.
Also of note: the method just below larger_than_max? is less_than_min? and no check for nil is made there either. So,
I suspect that this same error case may exist, though I have not exercised this condition.
|