module Crystallabs::Helpers::Format

Overview

Small formatting helpers.

Defined in:

crystallabs-helpers.cr

Class Method Summary

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).


[View source]
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).


[View source]