Module: ClassName::NumberConverter

Defined in:
lib/class_name/number_converter.rb

Class Method Summary collapse

Class Method Details

.to_word(integer) ⇒ String

Returns Converts the integer to the human word (up to 16 for our grids. Feel free to extend support).

Returns:

  • (String)

    Converts the integer to the human word (up to 16 for our grids. Feel free to extend support)



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/class_name/number_converter.rb', line 5

def to_word integer
  case integer
  when 0
    "zero"
  when 1
    "one"
  when 2
    "two"
  when 3
    "three"
  when 4
    "four"
  when 5
    "five"
  when 6
    "six"
  when 7
    "seven"
  when 8
    "eight"
  when 9
    "nine"
  when 10
    "ten"
  when 11
    "eleven"
  when 12
    "twelve"
  when 13
    "thirteen"
  when 14
    "fourteen"
  when 15
    "fifteen"
  when 16
    "sixteen"
  else
    integer
  end
end