Closed myoung34 closed 7 years ago
Yes, that's by design. to_i("MB")
won't make sense in the majority of cases, because you can't accurately express most sizes as an integer. That's why we're making the user go via to_f
+ an additional operation, to be explicit about the loss of resolution.
BTW, to_f("MB").to_i
is also only correct if the size is an even multiple of an MB, or if it'd round down to one, anyway. In the other cases, you want to round, not truncate.
Thanks for the quick response. I'll make sure my usage is "accurate" or at least documented. That makes sense, just wanted to double check
Im using this gem to sanitize user specified values.
I want whatever they have to go to 'MB'
But, i can't convert to an integer value without converting to a float then converting to an integer. is that by design?
The reason I have to do this is the API i'm integrating with requires an integer megabyte. If I provide a float, it errors.