lib/zold/size.rb in zold-0.21.1 vs lib/zold/size.rb in zold-0.21.2
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# Copyright (c) 2018 Yegor Bugayenko
+# Copyright (c) 2018-2019 Zerocracy, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -32,11 +32,12 @@
def initialize(bytes)
@bytes = bytes
end
def to_s
- return '?' if @bytes.nil?
- if @bytes < 1024
+ if @bytes.nil?
+ '?'
+ elsif @bytes < 1024
"#{@bytes}b"
elsif @bytes < 1024 * 1024
"#{(@bytes / 1024).round}Kb"
elsif @bytes < 1024 * 1024 * 1024
"#{(@bytes / (1024 * 1024)).round}Mb"