lib/timeframe.rb in timeframe-0.0.8 vs lib/timeframe.rb in timeframe-0.0.9
- old
+ new
@@ -1,17 +1,16 @@
-require 'rubygems'
+require 'date'
require 'active_support/version'
%w{
active_support/core_ext/array/extract_options
active_support/core_ext/string/conversions
active_support/core_ext/date/conversions
active_support/core_ext/integer/time
active_support/core_ext/numeric/time
}.each do |active_support_3_requirement|
require active_support_3_requirement
end if ActiveSupport::VERSION::MAJOR == 3
-require 'timeframe/ykk'
# Encapsulates a timeframe between two dates. The dates provided to the class are always until the last date. That means
# that the last date is excluded.
#
# # from 2007-10-01 00:00:00.000 to 2007-10-31 23:59:59.999
@@ -227,10 +226,13 @@
# escape
return [self] if timeframes.empty?
timeframes.sort! { |x, y| x.from <=> y.from }
- timeframes.collect(&:to).unshift(from).extend(Ykk).ykk(timeframes.collect(&:from).push(to)) do |gap|
+ a = [ from ] + timeframes.collect(&:to)
+ b = timeframes.collect(&:from) + [ to ]
+
+ a.zip(b).map do |gap|
Timeframe.new(*gap) if gap[1] > gap[0]
end.compact
end
# Returns true if the union of the given Timeframes includes the Timeframe