diff --git a/core/builtin.rbs b/core/builtin.rbs index 226d68b67..23b4265ea 100644 --- a/core/builtin.rbs +++ b/core/builtin.rbs @@ -6,6 +6,10 @@ interface _ToInt def to_int: -> Integer end +interface _ToR + def to_r: () -> Rational +end + interface _ToS def to_s: -> String end diff --git a/stdlib/date/0/date.rbs b/stdlib/date/0/date.rbs index 70be5e75a..e22e6db68 100644 --- a/stdlib/date/0/date.rbs +++ b/stdlib/date/0/date.rbs @@ -446,7 +446,7 @@ class Date # DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd # #=> # # - def +: (Integer | Rational other) -> Date + def +: ((Numeric & _ToR) other) -> Date # Returns the difference between the two dates if the other is a date object. # If the other is a numeric value, returns a date object pointing `other` days @@ -461,7 +461,7 @@ class Date # DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12) # #=> (1/2) # - def -: (Integer | Rational other) -> Date + def -: ((Numeric & _ToR) other) -> Date | (Date other) -> Rational # Returns a date object pointing `n` months before self. The argument `n` should