Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Ruby: set an interval for your Time (useful for ranges, especially) (See related posts)

   1  
   2  class Time
   3    def set_interval(seconds)
   4      @interval = seconds
   5    end
   6    def succ
   7      @interval ||= 1
   8      ret = self + @interval
   9      ret.set_interval(@interval)
  10      ret
  11    end
  12  end


You need to create an account or log in to post comments to this site.


Click here to browse all 5349 code snippets

Related Posts