mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
15 lines
No EOL
270 B
Ruby
15 lines
No EOL
270 B
Ruby
class Numeric
|
|
ONE_MEGABYTE = 1048576
|
|
|
|
def roundup(nearest=10)
|
|
self % nearest == 0 ? self : self + nearest - (self % nearest)
|
|
end
|
|
|
|
def to_mb
|
|
self/ONE_MEGABYTE.to_f
|
|
end
|
|
|
|
def to_space_pretty
|
|
"#{(self.to_f / ONE_MEGABYTE).round(2).to_s} MB"
|
|
end
|
|
end |