module Integer::SuuConstantsAndSubFunctions

Constants

Cen
Gin
Ichi
Juu
Man
Mi
One
Ten
Un

Public Instance Methods

gb(p) click to toggle source
# File lib/kgl/suu.rb, line 97
def gb(p)
        c = p.div(2)
        suf = (p%2==0 ? 'on' : 'ard')
        if c == 0
                p%2 == 0 ? '' : 'thousand'
        elsif c < 1000
                ret = ''
                if c < 10
                        ret = Mi[c] + 'illi' + suf + ret
                else
                        z = c.to_s
                        z = '0' + z if z.length == 2
                        if z[1..2].to_i<10
                                ret = Un[z[2..2].to_i] + 'tilli' + suf + ret
                        elsif z[1..2].to_i < 20
                                ret = Un[z[2..2].to_i] + 'decilli' + suf + ret
                        else
                                ret = Un[z[2..2].to_i] + Gin[z[1..1].to_i] + 'tilli' + suf + ret
                        end
                        ret = Cen[z[0..0].to_i] + ret
                end
                ret
        else
                c = c.to_s
                ret = ''
                x = c[-3, 3]
                if x[1..2].to_i < 10
                        ret = Un[x[2..2].to_i] + 'tilli' + suf + ret
                elsif x[1..2].to_i < 20
                        ret = Un[x[2..2].to_i] + 'decilli' + suf + ret
                else
                        ret = Un[x[2..2].to_i] + Gin[x[1..1].to_i] + 'tilli' + suf + ret
                end
                ret = Cen[x[0..0].to_i] + ret
                c = c[0..-4]
                m = 1
                while x = c[-3, 3]
                        ret = 'millia'*m + ret
                        ret = Un[x[2..2].to_i] + (x[1..2].to_i<10 ? '' : Gin[x[1..1].to_i]) + ret
                        ret = Cen[x[0..0].to_i] + ret
                        c = c[0..-4]
                        m += 1
                end
                if c != ''
                        ret = 'millia'*m + ret
                        if c.length == 1
                                c = '00' + c
                        elsif c.length == 2
                                c = '0' + c
                        end
                        ret = Un[c[2..2].to_i] + (c[1..2].to_i<10 ? '' : Gin[c[1..1].to_i]) + ret if c != '001'
                        ret = Cen[c[0..0].to_i] + ret
                end
                ret
        end
end
us(p) click to toggle source
# File lib/kgl/suu.rb, line 41
def us(p)
        if p == -1
                ''
        elsif p == 0
                'thousand'
        elsif p < 1000
                ret = ''
                if p < 10
                        ret = Mi[p] + 'illion' + ret
                else
                        z = p.to_s
                        z = '0' + z if z.length == 2
                        if z[1..2].to_i < 10
                                ret = Un[z[2..2].to_i] + 'tillion' + ret
                        elsif z[1..2].to_i < 20
                                ret = Un[z[2..2].to_i] + 'decillion' +  ret
                        else
                                ret = Un[z[2..2].to_i] + Gin[z[1..1].to_i] + 'tillion' + ret
                        end
                        ret = Cen[z[0..0].to_i] + ret
                end
                ret
        else
                c = p.to_s
                ret = ''
                x = c[-3, 3]
                if x[1..2].to_i < 10
                        ret = Un[x[2..2].to_i] + 'tillion' + ret
                elsif x[1..2].to_i < 20
                        ret = Un[x[2..2].to_i] + 'decillion' +  ret
                else
                        ret = Un[x[2..2].to_i] + Gin[x[1..1].to_i] + 'tillion' + ret
                end
                ret = Cen[x[0..0].to_i] + ret
                c = c[0..-4]
                m = 1
                while x = c[-3, 3]
                        ret = 'millia'*m + ret
                        ret = Un[x[2..2].to_i] + (x[1..2].to_i<10 ? '' : Gin[x[1..1].to_i]) + ret
                        ret = Cen[x[0..0].to_i] + ret
                        c = c[0..-4]
                        m += 1
                end
                if c != ''
                        ret = 'millia'*m + ret
                        if c.length == 1
                                c = '00' + c
                        elsif c.length == 2
                                c = '0' + c
                        end
                        ret = Un[c[2..2].to_i] + (c[1..2].to_i<10 ? '' : Gin[c[1..1].to_i]) + ret if c != '001'
                        ret = Cen[c[0..0].to_i] + ret
                end
                ret
        end
end