module
Crystallabs::Helpers::Format
Overview
Small formatting helpers.
Defined in:
crystallabs-helpers.crClass Method Summary
-
.humanize_bytes(bytes : Int) : String
Formats a byte count with the largest binary unit that keeps it >= 1, so small values stay in plain bytes (
842B) and large ones shrink toKiB/MiB/… with one decimal (3.2KiB). -
.truncate(str : String, len : Int32, marker : Char = '~') : String
Truncates str to len characters, replacing the last kept character with marker when cut (mutt/pine-style column truncation).
Class Method Detail
def self.humanize_bytes(bytes : Int) : String
#
Formats a byte count with the largest binary unit that keeps it >= 1, so
small values stay in plain bytes (842B) and large ones shrink to
KiB/MiB/… with one decimal (3.2KiB).
def self.truncate(str : String, len : Int32, marker : Char = '~') : String
#
Truncates str to len characters, replacing the last kept character with marker when cut (mutt/pine-style column truncation).