-
Notifications
You must be signed in to change notification settings - Fork 110
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
activesupport: Add types for to_fs #754
Conversation
dak2
commented
Dec 18, 2024
- ActiveSupport::NumericWithFormat
- https://api.rubyonrails.org/v7.0.8.6/classes/ActiveSupport/NumericWithFormat.html#method-i-to_fs
- ActiveSupport::RangeWithFormat
- https://api.rubyonrails.org/v7.0.8.6/classes/ActiveSupport/RangeWithFormat.html#method-i-to_fs
- Array
- https://api.rubyonrails.org/v7.0.8.6/classes/Array.html#method-i-to_fs
- Date
- https://api.rubyonrails.org/v7.0.8.6/classes/Date.html#method-i-to_fs
- DateTime
- https://api.rubyonrails.org/v7.0.8.6/classes/DateTime.html#method-i-to_fs
- Time
- https://api.rubyonrails.org/v7.0.8.6/classes/Time.html#method-i-to_fs
@dak2 Thanks for your contribution! Please follow the instructions below for each change. Available commandsYou can use the following commands by commenting on this PR.
|
# 1234567.to_fs(:human, precision: 1, | ||
# separator: ',', | ||
# significant: false) # => "1,2 Million" | ||
def to_fs: (?Symbol format, *untyped) -> String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second argument is a Hash object or kwargs.
https://github.com/rails/rails/blob/v7.0.8.7/activesupport/lib/active_support/core_ext/numeric/conversions.rb#L111
How about this?
def to_fs: (?Symbol format, *untyped) -> String | |
def to_fs: (?Symbol format, **untyped) -> String |
def to_fs: (?Symbol format, *untyped) -> String | |
def to_fs: (?Symbol format, Hash[untyped, untyped]?) -> String |
either is okay to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose **untyped
that simply statement. Thanks for pointing that out!
end | ||
|
||
# active_support/core_ext/date_time/conversions.rb | ||
class Datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
class Datetime | |
class DateTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, my bad! Thanks for noticing. I fixed it.
Note: refs: rails/rails#44354 |
- ActiveSupport::NumericWithFormat - https://api.rubyonrails.org/v7.0.8.6/classes/ActiveSupport/NumericWithFormat.html#method-i-to_fs - ActiveSupport::RangeWithFormat - https://api.rubyonrails.org/v7.0.8.6/classes/ActiveSupport/RangeWithFormat.html#method-i-to_fs - Array - https://api.rubyonrails.org/v7.0.8.6/classes/Array.html#method-i-to_fs - Date - https://api.rubyonrails.org/v7.0.8.6/classes/Date.html#method-i-to_fs - DateTime - https://api.rubyonrails.org/v7.0.8.6/classes/DateTime.html#method-i-to_fs - Time - https://api.rubyonrails.org/v7.0.8.6/classes/Time.html#method-i-to_fs
cb5f911
to
5000fe9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APPROVE
Thank you for your contribution! 🎉
/merge |