Module: NumbersAndWords::ArrayAdditions::Helpers
- Included in:
- FiguresArray
- Defined in:
- lib/numbers_and_words/array_additions/helpers.rb
Constant Summary collapse
- THOUSAND_CAPACITY =
1
Instance Method Summary collapse
- #capacity_count ⇒ Object
- #figures_array_in_capacity(capacity) ⇒ Object
- #hundreds ⇒ Object
- #is_a_thousand_capacity?(capacity) ⇒ Boolean
- #number_for_gender(capacity) ⇒ Object
- #number_in_capacity(capacity) ⇒ Object
- #ones ⇒ Object
- #teens ⇒ Object
- #tens ⇒ Object
- #tens_with_ones ⇒ Object
Instance Method Details
#capacity_count ⇒ Object
6 7 8 9 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 6 def capacity_count count = (self.length.to_f / 3).ceil 1 == count ? nil : count end |
#figures_array_in_capacity(capacity) ⇒ Object
11 12 13 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 11 def figures_array_in_capacity capacity self[capacity * 3, 3] end |
#hundreds ⇒ Object
45 46 47 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 45 def hundreds self[2] if 0 < self[2].to_i end |
#is_a_thousand_capacity?(capacity) ⇒ Boolean
25 26 27 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 25 def is_a_thousand_capacity? capacity THOUSAND_CAPACITY == capacity end |
#number_for_gender(capacity) ⇒ Object
19 20 21 22 23 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 19 def number_for_gender capacity figures = figures_array_in_capacity(capacity) teens = figures.teens teens ? teens.join.to_i : figures.first end |
#number_in_capacity(capacity) ⇒ Object
15 16 17 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 15 def number_in_capacity capacity figures_array_in_capacity(capacity).reverse.join.to_i end |
#ones ⇒ Object
29 30 31 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 29 def ones self[0] if 0 < self[0].to_i end |
#teens ⇒ Object
33 34 35 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 33 def teens tens_with_ones if 1 == tens end |
#tens ⇒ Object
37 38 39 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 37 def tens self[1] if self[1] and 0 < self[1].to_i end |
#tens_with_ones ⇒ Object
41 42 43 |
# File 'lib/numbers_and_words/array_additions/helpers.rb', line 41 def tens_with_ones [ones, tens] if ones and tens end |