Ruby, check if date is a weekend?

The simplest approach:

today = Date.today

if today.saturday? || today.sunday? 
  puts "Today is a weekend!"
end

You can also do this for any other day of the week. Ruby is fantastic and offers a lot of cool methods like this. I suggest when you get stumped take a look at what's available to the class by running .methods on it. So if you run Date.today.methods you will see these available.


TFM shows an interesting way to identifying the day of the week:

t = Time.now
t.saturday?    #=> returns a boolean value
t.sunday?      #=> returns a boolean value