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.rb47 chars3 lines
And here's an example using the Date
class:
main.rb65 chars5 lines
Both of these examples will output the current year.
gistlibby LogSnag