reduce precision to 1 digit

This commit is contained in:
Aart van Halteren
2013-07-31 11:58:29 +02:00
parent 68ca2bcf7a
commit 65b4d7aa5b

View File

@@ -11,4 +11,24 @@ class Reading < ActiveRecord::Base
self.high_tarif == reading.high_tarif
end
# reduce precision to 1 digit behind comma
def total_kwh_consumed_high=(kwh)
write_attribute(:total_kwh_consumed_high,kwh.round(1))
end
# reduce precision to 1 digit behind comma
def total_kwh_consumed_low=(kwh)
write_attribute(:total_kwh_consumed_low,kwh.round(1))
end
# reduce precision to 1 digit behind comma
def total_kwh_produced_high=(kwh)
write_attribute(:total_kwh_produced_high,kwh.round(1))
end
# reduce precision to 1 digit behind comma
def total_kwh_produced_low=(kwh)
write_attribute(:total_kwh_produced_low,kwh.round(1))
end
end