# Getting a 'true' value out of a method?

**URL:** <https://www.ruby-forum.com/t/getting-a-true-value-out-of-a-method/103648>\
**Category:** Rails\
**Created:** [May 8, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/getting-a-true-value-out-of-a-method/103648 "2007-05-08T22:03:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pat](https://www.ruby-forum.com/u/pat)\
**Post date:** [May 8, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/getting-a-true-value-out-of-a-method/103648/1 "2007-05-08T22:03:46Z")

</div>

Hi I wrote this method to check for the availability of a studio :

def check\_dispo(date, time, time\_duration, week\_duration)  
i = 0  
end\_time = time + time\_duration.strftime(’%H’).to\_i_3600 +  
time\_duration.strftime(’%M’).to\_i_60  
while i \< week\_duration  
studio\_bookings = StudioBooking.find(:all, :conditions =\>  
[“start\_date = ?”, date])  
for studio\_booking in studio\_bookings  
studio\_booking\_end\_time = studio\_booking.time +  
studio\_booking.time\_duration.strftime(’%H’).to\_i_3600 +  
studio\_booking.time\_duration.strftime(’%M’).to\_i_60  
unless time \>= studio\_booking\_end\_time || end\_time \<=  
studio\_booking.time  
return false  
end  
end  
i += 1  
date = date + 7  
end  
return true  
end

it returns false in case it’s booked but returns ‘nil’ instead of true  
otherwise ☹

HELP PLEASE !!!

Pat
