On Aug 22, 2010, at 7:59 PM, Ryan Davis wrote:
> On Aug 22, 2010, at 13:32 , Dick Davies wrote:
>
>> ?> class Fixnum
>>>> def percent
>
> the appropriate place to put that is Integer, not Fixnum.
>
>> % ruby -e 'p 100.class.superclass'
>> Integer

Or even Numeric:

irb> 1.class.ancestors
=> [Fixnum, Integer, Numeric, Comparable, Object, Kernel, BasicObject]
irb> class Numeric
irb>   def percent
irb>     self.to_f / 100.0
irb>     end
irb>   end
=> nil
irb> 5.percent
=> 0.05
irb> 125.percent
=> 1.25
irb> 14.7.percent
=> 0.147
irb> (99+"44/100".to_r).percent
=> 0.9944

-Rob

Rob Biedenharn		
Rob / AgileConsultingLLC.com	http://AgileConsultingLLC.com/
rab / GaslightSoftware.com		http://GaslightSoftware.com/