On Nov 17, 9:41 pm, Pokkai Dokkai <bad_good_l... / yahoo.com> wrote:
> now i am facing new problem....
>
> h={:a=>'aaa',:f=>BigDecimal.new("10")}
> h.inspect       -----> {:f=>#<BigDecimal:b7d77a3c,'0.1E2',4(8)>,
> :a=>"aaa"}
>
> i want like this----->{:f=>10, :a=>"aaa"}


irb(main):002:0> require 'bigdecimal'
=> true

irb(main):003:0> h = { :a=>'aaa', :f=>BigDecimal.new("10") }
=> {:f=>#<BigDecimal:34ab98,'0.1E2',4(8)>, :a=>"aaa"}

irb(main):005:0> h[:f].to_i
=> 10
irb(main):006:0> class BigDecimal; alias_method :inspect, :to_i; end
=> BigDecimal

irb(main):007:0> h
=> {:f=>10, :a=>"aaa"}


#inspect methods of classes that aggregate other instances tend to
call the #inspect of all those instances; you can customize the
inspect method of each class to customize its output. (Here I've just
said "make it so that when I call .inspect on a BigDecimal instance,
instead call the to_i method.")