After gathering data from a web service, I’m trying to pull out only those records that have a value for a particular field > 0. The field that I’m checking is a FixNum field. I have tried multiple things like .nil? or > 0 etc. But none of them seem to work.
Here is how the code goes:
results.each do |r|
# puts "came"
if r['efforRemaining'] % 1 != 0 #i tried r['efforRemaining'].nil? ..
# i have values like 0.4, 0.5 etc for the field, hence i need to check if the value is greater than 0 or not only
puts "came!"
puts "#{r['mstone']} ... #{r['assignee']['id']} ... #{r['effortRemaining'].to_f}"
end
end
Could somebody let me know how to do this?
thanks,
If
puts r['effortRemaining'].inspectcomes out in quote marks, that means it is a string and you need to convert it to a number before you compare it.This should work: