mirror of
https://github.com/neocities/neocities.git
synced 2025-06-29 07:33:26 +02:00
add format_large_numbers (via @violasong)
This commit is contained in:
parent
6593c9c2ed
commit
4af4347492
1 changed files with 12 additions and 0 deletions
|
@ -21,6 +21,18 @@ class Numeric
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_large_numbers
|
||||||
|
if self > 999999999
|
||||||
|
return sprintf "%.2fB", (self/1000000000.0)
|
||||||
|
elsif self > 999999
|
||||||
|
return sprintf "%.2fM", (self/1000000.0)
|
||||||
|
elsif self > 999
|
||||||
|
return sprintf "%.2fK", (self/1000.0)
|
||||||
|
else
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def to_space_pretty
|
def to_space_pretty
|
||||||
to_bytes_pretty
|
to_bytes_pretty
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue