3
4
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
|
# File 'lib/struggle/concerns/int_extend.rb', line 3
def uppercase
cstr = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"]
cn_nums1 = ["元", "拾", "佰", "仟", "萬", "拾", "佰", "仟", "億", "拾", "佰", "仟"]
cn_nums2 = ['分', '角']
s = ""
array = self.to_s.split(".")
p h = array[0].to_s.split(//)
ai = h.count
h.each_with_index do |a, j|
s+=cstr[a.to_i]+cn_nums1[ai-1]
ai=ai-1
end
p h1 = array[1].to_s.split(//)
aj = h1.count
h1.each_with_index do |o, p|
s+=cstr[o.to_i]+cn_nums2[aj-1]
aj=aj-1
end
rstr = ""
rstr=s.gsub("拾零", "拾")
rstr=rstr.gsub("零拾", "零");
rstr=rstr.gsub("零佰", "零");
rstr=rstr.gsub("零仟", "零");
rstr=rstr.gsub("零萬", "萬");
for i in 1..6 do
rstr=rstr.gsub("零零", "零");
rstr=rstr.gsub("零萬", "零");
rstr=rstr.gsub("零億", "億");
rstr=rstr.gsub("零零", "零");
end
rstr=rstr.gsub("零角", "零");
rstr=rstr.gsub("零分", "");
rstr=rstr.gsub("零元", "");
end
|