find the current year in ruby

You can find the current year in Ruby using the Time class from the time module or the Date class from the date module.

Here's an example using the Time class:

main.rb
current_year = Time.now.year
puts current_year
47 chars
3 lines

And here's an example using the Date class:

main.rb
require 'date'

current_year = Date.today.year
puts current_year
65 chars
5 lines

Both of these examples will output the current year.

gistlibby LogSnag