Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/to_cardinal.rb

Instance Method Summary collapse

Instance Method Details

#to_cardinalObject



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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/to_cardinal.rb', line 6

def to_cardinal
  case self.downcase
  when 'first', '1st'
    1
  when 'second', '2nd'
    2
  when 'third', '3rd'
    3
  when 'fourth', '4th'
    4
  when 'fifth', '5th'
    5
  when 'sixth', '6th'
    6
  when 'seventh', '7th'
    7
  when 'eighth', '8th'
    8
  when 'ninth', '9th'
    9
  when 'tenth', '10th'
    10
  when 'eleventh', '11th'
    11
  when 'twelfth', '12th'
    12
  when 'thirteenth', '13th'
    13
  when 'fourteenth', '14th'
    14
  when 'fifteenth', '15th'
    15
  when 'sixteenth', '16th'
    16
  when 'seventeenth', '17th'
    17
  when 'eighteenth', '18th'
    18
  when 'nineteenth', '19th'
    19
  when 'twentieth', '20th'
    20
  when 'thirtieth', '30th'
    30
  when 'fortieth', '40th'
    40
  when 'fiftieth', '50th'
    50
  when 'sixtieth', '60th'
    60
  when 'seventieth', '70th'
    70
  when 'eightieth', '80th'
      80
  when 'ninetieth', '90th'
    90
  when 'hundredth', '100th'
    100
  else
    -1
  end
end