Skip to content

Commit 503a14d

Browse files
committed
More exact quantization on searching
1 parent 809ddc0 commit 503a14d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/nom/nom.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def search args
121121
size = serving.css("a.servb").text
122122
kcal = serving.css("div")[5].css("div")[1].text.to_i
123123
#kj = serving.css("div")[2].css("div")[1].text.to_i
124-
puts " (#{quantize(kcal)}) #{size}"
124+
puts " (#{quantize(kcal,1)}) #{size}"
125125
end
126126
end
127127
end
@@ -306,8 +306,8 @@ def truncate_date
306306
end
307307
end
308308

309-
def quantize kcal
310-
(1.0*kcal/@config.get("unit")).round
309+
def quantize kcal, decimal_places=0
310+
(1.0*kcal/@config.get("unit")).round(decimal_places)
311311
end
312312

313313
def dequantize number

0 commit comments

Comments
 (0)