Reputation: 21
I want to round of the ones and tens digit positon for the value..
if it is 1999, it should display as 1900
and if it is 19999 it should display as 19000
code goes like this
Upvotes: 1
Views: 1170
Reputation: 107969
You can round like this:
(n.to_i / 100) * 100
However, you are asking for a monkey patch so that :nocents is a valid argument to... money, I guess. I poked around the rails source and didn't see where the monkey patch should go.
Upvotes: 6
Reputation: 37906
You could use something like this:
def myround(value)
return value if value < 100
temp = value.to_s
temp[0..1] + "0" * (temp.lenth - 2)
end
Upvotes: 0