Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add duration methods to Numeric #166

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"requires": [
"active_support",
"active_support/core_ext/array",
"active_support/core_ext/numeric/time",
"active_support/core_ext/integer/time",
"active_support/test_case"
]
},
Expand Down
40 changes: 40 additions & 0 deletions rbi/annotations/activesupport.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,46 @@ class Hash
def extractable_options?; end
end

class Integer
sig { returns(ActiveSupport::Duration) }
def months; end
sig { returns(ActiveSupport::Duration) }
def month; end
sig { returns(ActiveSupport::Duration) }
def years; end
sig { returns(ActiveSupport::Duration) }
def year; end
end

class Numeric
sig { returns(ActiveSupport::Duration) }
def seconds; end
sig { returns(ActiveSupport::Duration) }
def second; end
sig { returns(ActiveSupport::Duration) }
def minutes; end
sig { returns(ActiveSupport::Duration) }
def minute; end
sig { returns(ActiveSupport::Duration) }
def hours; end
sig { returns(ActiveSupport::Duration) }
def hour; end
sig { returns(ActiveSupport::Duration) }
def days; end
sig { returns(ActiveSupport::Duration) }
def day; end
sig { returns(ActiveSupport::Duration) }
def weeks; end
sig { returns(ActiveSupport::Duration) }
def week; end
sig { returns(ActiveSupport::Duration) }
def fortnight; end
sig { returns(ActiveSupport::Duration) }
def fortnights; end
sig { returns(Integer) }
def in_milliseconds; end
end

class Array
sig { params(position: Integer).returns(T.self_type) }
def from(position); end
Expand Down