Module: Parayaz

Included in:
Numeric
Defined in:
lib/parayaz.rb,
lib/parayaz/version.rb

Constant Summary collapse

VERSION =
'1.0.3'

Instance Method Summary collapse

Instance Method Details

#parayazObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/parayaz.rb', line 4

def parayaz
  number = self
  minus = number < 0

  number *= -1 if minus

  price, cents = number.to_s.split('.')

  text = convert_to_text(price) + 'TL'
  if cents && cents.to_i > 0
    if cents.size == 1
      cents = (cents.to_i * 10).to_s
    end

    if cents.size > 2
      cents = cents[0..1]
    end

    text += ',' + convert_to_text(cents) + 'kr'
  end

  (minus ? 'eksi' : '') + text + '.'
end