We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, in our application, we need to generate words from number including an unit.
I've done the following quick-and-dirty patch which works for us, but would need more work to be included in this gem.
I'm including it here for anyone interested :
module NumbersAndWords module Wrappers class Float ZERO_SYMBOL = '0'.freeze attr_accessor :number def initialize(number) @number = number end def to_words(options = {}) @options = options words = [] words << add_unit_to(integral_part_with(options), options) words << fractional_part_with(options) unless fractional_part_is_nil? NumbersAndWords::WordsArray.new(words).join options end private def add_unit_to(words, options) return unless options[:unit] i18n_options = { count: number.abs.floor, scope: :numbers } words_array = words.split(' ') words_array << ::I18n.t(options[:unit], i18n_options) words_array.join(' ') end end end end
Caveats that might need to be addressed for a PR:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, in our application, we need to generate words from number including an unit.
I've done the following quick-and-dirty patch which works for us, but would need more work to be included in this gem.
I'm including it here for anyone interested :
Caveats that might need to be addressed for a PR:
The text was updated successfully, but these errors were encountered: