Supporting fractions in Ruby/Rails
28-Oct-2021 1277
Unicode comes with a selection of common single-character fractions like ½, ¼, and even ⅐ (see en.wikipedia.org/wiki/Number_Forms for more), but I need to store and display somewhat arbitrary fractions in a Rails app and it isn’t something I’ve had to do before so I’m documenting my workings.Ruby has the Rational class that makes it easy to work with fractions and can perform a specific calculation I need (½ ⅐ = ⁹⁄₁₄):.
Supporting fractions in Ruby/Rails #ruby #rubydeveloper #rubyonrails #Supporting #fractions #Ruby/Rails https://rubyonrails.ba/link/supporting-fractions-in-ruby-rails