Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Range#min, Range#max for Time range on X19

  • Loading branch information...
commit 04c2c40d5973924c42132dd768b6fde5186e001d 1 parent f0bd4cb
@kachick kachick authored
Showing with 16 additions and 7 deletions.
  1. +16 −7 kernel/common/range19.rb
View
23 kernel/common/range19.rb
@@ -12,19 +12,28 @@ def first(n=undefined)
end
def max(&block)
- raise TypeError, "cannot exclude non Integer end value" if @end.kind_of?(Float) && @excl
+ return super(&block) if block_given? || (@excl && !@end.kind_of?(Numeric))
+ return nil unless @end > @begin
- return super(&block) if block_given?
- return nil if @end < @begin || (@excl && @end == @begin)
- return @end if @end.kind_of?(Float) || (!@end.kind_of?(Float) && !@excl)
- super
+ if @excl
+ unless @end.kind_of?(Integer)
+ raise TypeError, "cannot exclude non Integer end value"
+ end
+
+ unless @begin.kind_of?(Integer)
+ raise TypeError, "cannot exclude end value with non Integer begin value"
+ end
+
+ return @end - 1
+ end
+
+ @end
end
def min(&block)
return super(&block) if block_given?
return nil if @end < @begin || (@excl && @end == @begin)
- return @begin if @begin.kind_of?(Float)
- super
+ @begin
end
protected
Please sign in to comment.
Something went wrong with that request. Please try again.