-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to use gigabytes instead of gigibytes (#1798)
* default base is now 1000 * added test to check for file size with 1000 base * Added a few tests to make sure the base parameter is honored Co-authored-by: Claudia Lee <[email protected]> * Adjusted test to use KB instead of KiB --------- Co-authored-by: Hector Correa <[email protected]> Co-authored-by: Claudia Lee <[email protected]>
- Loading branch information
1 parent
0e5bb4f
commit 410bed2
Showing
3 changed files
with
32 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
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