From eb6ee05a3e83ab39547dfd986da0d7ed49e3aea7 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 29 Jul 2010 14:01:12 +0300 Subject: [PATCH] Reordered iteration methods. --- lib/time_ext/core_ext/time/iterations.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/time_ext/core_ext/time/iterations.rb b/lib/time_ext/core_ext/time/iterations.rb index 93d8860..bace2e8 100644 --- a/lib/time_ext/core_ext/time/iterations.rb +++ b/lib/time_ext/core_ext/time/iterations.rb @@ -25,6 +25,15 @@ class Time end end + # Used togeter with #each to specify end of interation. + def until(time, &block) + time = time.to_time if time.is_a?(::Date) + @until = time + return call_chain(block) if block_given? + self + end + alias :till :until + # Executes passed block for each "unit" of time specified, with a new time object for each interval passed to the block. def each(unit, options = {}, &block) iterate(unit, options.merge(:map_result => false), &block) @@ -45,15 +54,6 @@ class Time iterate(unit, options.merge(:map_result => true, :beginning_of => true), &block) end - # Used togeter with #each to specify end of interation. - def until(time, &block) - time = time.to_time if time.is_a?(::Date) - @until = time - return call_chain(block) if block_given? - self - end - alias :till :until - # Dynamically define convenience methods, like #each_hour instead of #each(:hour). [:year, :month, :day, :hour, :min, :minute, :sec, :second].each do |unit| [:each, :beginning_of_each, :map_each, :map_beginning_of_each].each do |method|