elixir-rational icon indicating copy to clipboard operation
elixir-rational copied to clipboard

[Feature Request] - Parse Rational Number From String

Open daidoji opened this issue 1 year ago • 0 comments

Although not too heavy a lift in code, it would be nice if the library parsed a rational number from a string into its representation (and maybe serialized to a pure text representation that wasn't the bin version already present) so that these values could be embedded into text or other serialization types.

ie) Ratio.from_binary("1/2") -> Ratio.new(1, 2) Ratio.from_binary("5000/2") -> Ratio.new(5000, 2) Ratio.from_binary("1") -> Ratio.new(1, 1) Ratio.from_binary("foo_bar") -> {:error, "foo_bar is not a numeric representation"}

daidoji avatar Sep 28 '24 13:09 daidoji