quantity icon indicating copy to clipboard operation
quantity copied to clipboard

ArgumentError: Unknown target unit type: ary

Open brundage opened this issue 13 years ago • 2 comments

1.9.3p0 :001 > require 'quantity'
 => true 
1.9.3p0 :002 > Quantity::VERSION
 => 0.1.2 
1.9.3p0 :003 > [1.gallon, 1.gallon].flatten
ArgumentError: Unknown target unit type: ary
    from /home/brundage/.rvm/gems/ruby-1.9.3-p0/gems/quantity-0.1.2/lib/quantity.rb:356:in `method_missing'
    from (irb):3:in `flatten'
    from (irb):3
    from /home/brundage/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

brundage avatar Aug 27 '12 05:08 brundage

This would be a result of Ruby 1.9's new flattening behavior. Quantity is incorrectly assuming here that to_* is a unit conversion attempt and failing; it should probably return NoMethodError instead, which would fix the flattening and probably some other unknown bugs. See http://yehudakatz.com/2010/01/02/the-craziest-fing-bug-ive-ever-seen/

In other news, I don't really work on this anymore, but am happy to give you gem push rights if you're running with it.

bhuga avatar Aug 27 '12 06:08 bhuga

I patched it by calling super. I'll change to NoMethodError & submit a pull.

Thanks, I'll take gem push rights. I'm brundage on rubygems. Would you add me as a collaborator on this repo too?

brundage avatar Aug 31 '12 00:08 brundage