lib/timespan.rb in timespan-0.5.7 vs lib/timespan.rb in timespan-0.5.9

- old
+ new

@@ -1,10 +1,9 @@ require 'duration' require 'chronic' require 'chronic_duration' require 'spanner' -require 'time-lord' # Range intersection that works with dates! require 'sugar-high/range' require 'sugar-high/delegate' require 'sugar-high/kind_of' @@ -55,20 +54,23 @@ @init_options = options validate! if options == {} options = {:duration => options} if options.kind_of? Numeric - case options - when TimeLord::Period, ::Duration, String + if duration_classes.any?{|clazz| options.kind_of? clazz } options = {:duration => options} end configure! options @is_new = false end + def duration_classes + [::Duration, ::String] + end + def asap! @asap = true end def asap= value @@ -193,24 +195,20 @@ Chronic.parse(time) when Date, DateTime time.to_time when Duration (Time.now + time).to_time - when TimeLord::Period - (Time.now + time).to_time - when TimeLord::Time - (Time.now + time.moment).to_time when Time time else raise ArgumentError, "A valid time must be one of #{valid_time_classes.inspect}, was: #{time.inspect} (#{time.class})" end end protected def valid_time_classes - [String, Duration, Date, Time, DateTime, TimeLord::Period, TimeLord::Time] + [String, Duration, Date, Time, DateTime] end attr_reader :init_options def first_from keys, options = {} \ No newline at end of file