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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/torupees.rb', line 23
def to_rupaiya
string = self.to_s.gsub(/\s+/, "")
decimalcheck = string.index('.')
if (decimalcheck != nil )
paisa = string[decimalcheck+1 .. decimalcheck+2 ]
else
p = false
paisa = '0'
end
num = self.to_i
num, sign = check_sign(num)
return (sign + NEPALI_NUMBERS[num] + " ।" + paisa.to_i.to_rupaiya) if (num <= 100 && paisa.to_i != 0)
return "०" if (num == 0 && paisa.to_i == 0)
return (sign + NEPALI_NUMBERS[num]) if (num <=100 && paisa.to_i == 0)
counter = 0
result = []
while num != 0
if (num > 10000000000000000)
return false
elsif ((num / 1000000000000000) >= 1)
test , remaining = num.divmod(1000000000000000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999999
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999999999
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999999999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999999999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+ "."+ paisa).to_rupaiya )
elsif ((num / 10000000000000) >= 1)
test , remaining = num.divmod(10000000000000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999999
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999999
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999999999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya )
elsif ((num / 100000000000) >= 1)
test , remaining = num.divmod(100000000000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya )
elsif ((num / 1000000000) >= 1)
test , remaining = num.divmod(1000000000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya )
elsif ((num / 10000000) >= 1)
test , remaining = num.divmod(10000000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya )
elsif ((num / 100000) >= 1)
test , remaining = num.divmod(100000)
return ((sign + NEPALI_NUMBERS[test]) +",००,००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",००,०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +",००,"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 999
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9999
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya )
elsif ((num / 1000) >= 1)
test , remaining = num.divmod(1000)
return ((sign + NEPALI_NUMBERS[test]) +",००"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 9
return ((sign + NEPALI_NUMBERS[test]) +",०"+ (remaining.to_s+"."+paisa).to_rupaiya) if remaining <= 99
return ((sign + NEPALI_NUMBERS[test]) +","+ (remaining.to_s+"."+paisa).to_rupaiya)
end
num, remaining = num.divmod(100)
if remaining <=9
temp_result = (sign + NEPALI_NUMBERS[num]) + "०" + (NEPALI_NUMBERS[remaining])
else
temp_result = (sign + NEPALI_NUMBERS[num]) + (NEPALI_NUMBERS[remaining])
end
result = temp_result + " ।" + paisa.to_i.to_rupaiya
return result
end
end
|