Module: TUI::Formatting
- Included in:
- Decorators::BaseDecorator, Screens::Chat
- Defined in:
- lib/tui/formatting.rb
Overview
Shared formatting helpers for timestamps and token counts. Used by both the Chat screen and client-side decorators to avoid duplicating display logic.
Instance Method Summary collapse
-
#format_ns_timestamp(ns) ⇒ String
Converts nanosecond-precision timestamp to human-readable HH:MM:SS.
-
#format_token_label(tokens, estimated) ⇒ String
Formats a token count for display, with tilde prefix for estimates.
Instance Method Details
#format_ns_timestamp(ns) ⇒ String
Converts nanosecond-precision timestamp to human-readable HH:MM:SS.
22 23 24 25 26 |
# File 'lib/tui/formatting.rb', line 22 def (ns) return "--:--:--" unless ns Time.at(ns / 1_000_000_000.0).strftime("%H:%M:%S") end |
#format_token_label(tokens, estimated) ⇒ String
Formats a token count for display, with tilde prefix for estimates.
12 13 14 15 16 17 |
# File 'lib/tui/formatting.rb', line 12 def format_token_label(tokens, estimated) return "" unless tokens label = estimated ? "~#{tokens}" : tokens.to_s "[#{label} tok]" end |