Module: NumbersHelper
- Included in:
- Organizations::OrganizationAssociationCounter
- Defined in:
- app/helpers/numbers_helper.rb
Constant Summary collapse
- WORDS =
%w[zero one two three four five six seven eight nine].freeze
Instance Method Summary collapse
Instance Method Details
#limited_counter_with_delimiter(resource, **options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/numbers_helper.rb', line 6 def limited_counter_with_delimiter(resource, **) limit = .fetch(:limit, 1000).to_i count = resource.page.total_count_with_limit(:all, limit: limit) if count > limit "#{number_with_delimiter(count - 1, )}+" elsif count == 0 .fetch(:include_zero, true) ? "0" : nil else number_with_delimiter(count, ) end end |
#number_in_words(num) ⇒ Object
19 20 21 22 23 |
# File 'app/helpers/numbers_helper.rb', line 19 def number_in_words(num) raise ArgumentError, _('Input must be an integer between 0 and 9') unless num.between?(0, 9) WORDS[num] end |