I have a ruby variable 'is_published'. I want to convert the value in 'is_published' to integer. Is there any method in ruby to do that?
if is_published == true
is_published = 1
else
is_published = 0
end
The above code works perfectly. Please help if there is any way to do this in a single line code.
is_published = is_published? 1: 0;I don't know the syntax of ruby, I use this in jsis_published = (is_published && 1) || (is_published || 0)is another way.(is_published && 1) || 0, @CarySwovelandis_published ? 1 : 0. Boring, perhaps, but reads the best.