Sha256: cbddcb96e2bf4125afc6fcf70679179023278c25590c597115ab20b4ed97cec9
Contents?: true
Size: 619 Bytes
Versions: 1
Compression:
Stored size: 619 Bytes
Contents
# frozen_string_literal: true module HelpersView # module RenderFileSize module RenderFileSize def render_file_size_html(file_size, number_round = 2) return "#{file_size} B" if file_size < 1024 return "#{(file_size / 1024.0).round(number_round)} KB" if file_size < 1024 * 1024 return "#{(file_size / (1024.0 * 1024)).round(number_round)} MB" if file_size < 1024 * 1024 * 1024 return "#{(file_size / (1024.0 * 1024 * 1024)).round(number_round)} GB" if file_size < 1024 * 1024 * 1024 * 1024 "#{(file_size / (1024.0 * 1024 * 1024 * 1024)).round(number_round)} TB" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
helpers_view-0.1.0 | lib/helpers_view/render_file_size.rb |