Module: WSDL::Formatting
- Defined in:
- lib/wsdl/formatting.rb
Overview
Formatting utilities for human-readable output.
Provides module functions for formatting values in error messages, inspect output, and logs.
Class Method Summary collapse
-
.format_bytes(bytes) ⇒ String
Formats a byte count for human-readable display.
Class Method Details
.format_bytes(bytes) ⇒ String
Formats a byte count for human-readable display.
Converts byte counts to appropriate units (B, KB, MB) for readability. Returns 'unlimited' for nil values, which represent disabled limits.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/wsdl/formatting.rb', line 30 def format_bytes(bytes) return 'unlimited' if bytes.nil? if bytes >= 1024 * 1024 "#{bytes / (1024 * 1024)}MB" elsif bytes >= 1024 "#{bytes / 1024}KB" else "#{bytes}B" end end |