Ruby - Extend Fixnum to extend number

Introduction

You can extend the Fixnum class with some helper methods to make manipulating dates easier:

Demo

class Fixnum 
  def seconds # from   ww  w. j a  v a  2 s .  co m
    self 
  end 
  def minutes 
    self * 60 
  end 
  def hours 
    self * 60 * 60 
  end 
  def days 
    self * 60 * 60 * 24 
  end 
end 

puts Time.now 
puts Time.now + 10.minutes 
puts Time.now + 16.hours 
puts Time.now - 7.days

Result