-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monkey-patch Rails number_to_human_size_converter. (#621)
* Monkey-patch Rails number_to_human_size_converter. * Rubocop nit-picking
- Loading branch information
1 parent
eb926bb
commit 5ca7bfa
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
# Source: https://github.com/rails/rails/issues/40054#issuecomment-674449143 | ||
# Additional information: https://massive.io/file-transfer/gb-vs-gib-whats-the-difference/ | ||
module ActiveSupport | ||
module NumberHelper | ||
class NumberToHumanSizeConverter < NumberConverter | ||
private | ||
|
||
# Allows a base to be specified for the conversion | ||
# 1024 was the default and that produces gigibytes | ||
# 1000 produces gigabytes | ||
def base | ||
options[:base] || 1000 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters