Closed imerr closed 9 years ago
Will decide on this change later, but it definitely makes me regret that the existing regexps are case insensitive, because MB
is a megabyte, whereas Mb
would be a megabit. Mbit
reads a bit funny to me.
I think it being very explicit is actually a good thing if you use it to parse user-input. I'd imagine lots of people just putting it in all lower case, this prevents accidental misunderstandings - not to mention bit isnt exactly a unit people use a lot.
not to mention bit isnt exactly a unit people use a lot
It's also technically not a unit used for file sizes, but of course it's used in combination with file sizes (as in your use case). I'm neither happy about case insensitive units, nor about supporting "Mbit" but not "Mb" to mean Megabit, but we cannot change it to being case sensitive now, as that'd probably break a lot of code, and users do indeed often not use appropriate casing.
Sorry, but I don't think I can merge this as long as filesize
ignores casing. If we supported Mbit
, people might use Mb
expecting it to mean Mbit
. But instead, their values would be treated as MB
, that can be a rather problematic bug.
If we ever release another, backwards incompatible, version of filesize that respects casing, we'll include bit-sizes.
Commonly used for network bandwidths (that's what I need it for anyways)
Hope the code isn't too ugly, feel free to improve it/suggest improvements - I'm a ruby newbie
quick example