Skip to content

Instantly share code, notes, and snippets.

@cbguder
Created May 7, 2009 13:27
Show Gist options
  • Save cbguder/108089 to your computer and use it in GitHub Desktop.
Save cbguder/108089 to your computer and use it in GitHub Desktop.
def yaziyla(amount)
r = ''
if amount >= 2000
r += yaziyla_part(amount / 1000) + 'BİN'
elsif amount >= 1000
r += 'BİN'
end
r += yaziyla_part(amount % 1000) + ' TL'
kurus = (amount * 100) % 100
if kurus > 0
r += ' ' + yaziyla_part((amount * 100) % 100) + ' KR'
end
return r
end
def yaziyla_part(amount)
ones = [ '', 'BİR', 'İKİ', 'ÜÇ', 'DÖRT', 'BEŞ', 'ALTI', 'YEDİ', 'SEKİZ', 'DOKUZ' ]
tens = [ '', 'ON', 'YİRMİ', 'OTUZ', 'KIRK', 'ELLİ', 'ALTMIŞ', 'YETMİŞ', 'SEKSEN', 'DOKSAN' ]
hundreds = [ '', 'YÜZ', 'İKİYÜZ', 'ÜÇYÜZ', 'DÖRTYÜZ', 'BEŞYÜZ', 'ALTIYÜZ', 'YEDİYÜZ', 'SEKİZYÜZ', 'DOKUZYÜZ' ]
return hundreds[amount/100] + tens[(amount % 100) / 10] + ones[(amount % 10)]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment