mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
round the pretty file size
This commit is contained in:
parent
cc659b6eda
commit
b6342c3ef4
1 changed files with 11 additions and 1 deletions
|
@ -280,11 +280,21 @@ module ColorLS
|
|||
end
|
||||
|
||||
def justify_size_info(size)
|
||||
size_num = size[0][0..-4].rjust(chars_for_size, ' ')
|
||||
size_num = displayable_size_num(size[0]).rjust(chars_for_size, ' ')
|
||||
size_unit = @show_human_readable_size ? size[1].ljust(3, ' ') : size[1]
|
||||
"#{size_num} #{size_unit}"
|
||||
end
|
||||
|
||||
def displayable_size_num(size_num_str)
|
||||
digit_after_decimal = size_num_str[-2]
|
||||
if %w[5 6 7 8 9].include?(digit_after_decimal)
|
||||
num = size_num_str.to_i
|
||||
return (num + 1).to_s
|
||||
end
|
||||
|
||||
size_num_str[0..-4]
|
||||
end
|
||||
|
||||
def clear_chars_for_size
|
||||
@chars_for_size = nil
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue