module

Mangrullo::StringDisplayUtils

Utility methods for string display formatting

Class methods

escape_html(text : String) : String

Escape HTML entities

Source
format_bytes(bytes : Int) : String

Format bytes in human-readable format

Source
format_duration(seconds : Int) : String

Format a duration in human-readable format

Source
highlight_diff(old_text : String, new_text : String) : String

Highlight differences between two strings

Source
string_to_color(text : String, saturation : Int32 = 70, lightness : Int32 = 50) : String

Generate a color based on string hash (for consistent coloring)

Source
time_ago(time : Time) : String

Format a timestamp relative to now

Source
title_case(text : String) : String

Convert to title case

Source
truncate(text : String | Nil, max_length : Int32, ellipsis : String = "...") : String

Truncate string with ellipsis

Source
truncate_middle(text : String | Nil, max_length : Int32, ellipsis : String = "...") : String

Truncate from the middle (useful for IDs)

Source
truncate_start(text : String | Nil, max_length : Int32, ellipsis : String = "...") : String

Truncate the beginning of a string

Source