module NumbersAndWords::ArrayExtensions::Helpers
Constants
- FIGURES_IN_CAPACITY
- MICRO_CAPACITY_SHIFT
- ONES_SHIFT
- THOUSAND_CAPACITY
Public Instance Methods
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 15 def capacity_count count = capacity_length / FIGURES_IN_CAPACITY count.zero? ? nil : count end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 11 def capacity_length length - ONES_SHIFT end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 20 def figures_array_in_capacity(capacity) self[capacity * FIGURES_IN_CAPACITY, FIGURES_IN_CAPACITY] end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 37 def figures_array_under_capacity(capacity) self[0..(capacity * FIGURES_IN_CAPACITY) - ONES_SHIFT] end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 73 def fraction_capacity [fraction_capacity_count, fraction_sub_capacity] end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 77 def fraction_capacity_count capacity_count.nil? ? sub_capacity : capacity_count + MICRO_CAPACITY_SHIFT end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 81 def fraction_sub_capacity sub_capacity unless capacity_count.nil? end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 61 def hundreds self[2].to_i if self[2].to_i.positive? end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 24 def number_in_capacity(capacity) figures_array_in_capacity(capacity).reverse.join.to_i end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 28 def number_under_capacity(capacity) figures_array_under_capacity(capacity).reverse.join.to_i end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 41 def ones self[0].to_i if self[0].to_i.positive? end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 45 def only_ones ones if !tens && !hundreds end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 32 def opaque?(capacity) figures_under = figures_array_under_capacity(capacity) figures_under.count(0) == figures_under.length end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 89 def ordinal_capacity count = ordinal_index / FIGURES_IN_CAPACITY count.zero? ? nil : count end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 85 def ordinal_index index(&:positive?) end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 65 def round_hundred? ones.nil? && tens.nil? end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 69 def sub_capacity capacity_length % FIGURES_IN_CAPACITY end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 49 def teens tens_with_ones if tens == 1 end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 53 def tens self[1].to_i if self[1].to_i.positive? end
Source
# File lib/numbers_and_words/helper_classes/array_extensions/helpers.rb, line 57 def tens_with_ones [ones, tens] if ones && tens end