Module: ContextSpook::Utils

Defined in:
lib/context_spook/utils.rb

Overview

The ContextSpook::Utils module provides utility methods for formatting and processing context data.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format_size(context_size) ⇒ String

The format_size method converts a byte size value into a human-readable string with binary units.

This method takes a raw byte count and formats it using the Tins::Unit library to display the size with appropriate binary prefixes (KiB, MiB, etc.) and two decimal places.

Parameters:

  • context_size (Integer)

    the size in bytes to be formatted

Returns:

  • (String)

    the formatted size string with binary units



16
17
18
# File 'lib/context_spook/utils.rb', line 16

def format_size(context_size)
  Tins::Unit.format(context_size, format: '%.2f %U', unit: ?b, prefix: 1024)
end

Instance Method Details

#format_size(context_size) ⇒ String (private)

The format_size method converts a byte size value into a human-readable string with binary units.

This method takes a raw byte count and formats it using the Tins::Unit library to display the size with appropriate binary prefixes (KiB, MiB, etc.) and two decimal places.

Parameters:

  • context_size (Integer)

    the size in bytes to be formatted

Returns:

  • (String)

    the formatted size string with binary units



16
17
18
# File 'lib/context_spook/utils.rb', line 16

def format_size(context_size)
  Tins::Unit.format(context_size, format: '%.2f %U', unit: ?b, prefix: 1024)
end