Skip to content

Add facets/bytes, for sizes in bytes - #356

Merged
trans merged 1 commit into
mainfrom
feature/bytes
Nov 29, 2026
Merged

trans merged 1 commit into
mainfrom
feature/bytes

Conversation

@trans

@trans trans commented Nov 29, 2026

Copy link
Copy Markdown
Member

A standard library, loaded with require 'facets/bytes' and not by require 'facets'.

1.kilobyte              #=> 1024
2.megabytes             #=> 2097152
512.bytes               #=> 512
2.megabytes.strfbytes   #=> "2.00 MB"
  • bytes, and kilobytes through yottabytes, each with its singular. Each unit is 1024 of the one before, and the result is a plain number of bytes.
  • It loads Numeric#strfbytes along with them.
  • The names and results are ActiveSupport's; I compared all eight that it has against ActiveSupport 8.1.4.1. yottabytes is an addition, since strfbytes goes up to YB.
  • The methods are in an included module (Numeric::Bytes), so where ActiveSupport has defined them on Numeric itself, its own are the ones used, whichever loads first.

Also removes the four commented-out, bit-based byte methods from facets/multipliers, and points from there to this.

10 tests; the whole suite passes.

🤖 Generated with Claude Code

2.megabytes and so on, as multiples of 1024 bytes, with the names and
results of ActiveSupport. Removes the commented-out bit-based methods
from facets/multipliers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@trans
trans merged commit 11d737f into main Nov 29, 2026
16 checks passed
@trans
trans deleted the feature/bytes branch November 29, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant