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
37
38
39
40
41
42
43
|
# File 'lib/azn_converter/convert.rb', line 9
def to_azn(options = {})
options[:current] ||= true
int = self
if options[:current] == true
if options[:from] == :azn
value = int
else
if AZNConverter::Convert::has_connection?
value = AZNConverter::Convert::get_currency(int, options[:from] || :usd)
else
return 'No Connection'
end
end
elsif options[:current] > 0
value = int * options[:current]
else
return nil
end
if options[:words]
if value.is_a? Integer
value = value.humanize(locale: :az) + ' manat'
elsif value.is_a? Float
value = "%.2f" % value
value = begin
w = value.to_i.humanize(locale: :az) + ' manat '
w += (value.to_s[(value.to_s.index('.') + 1)..(value.to_s.index('.') + 2)]).to_i.humanize(locale: :az) + ' qəpik'
end
end
end
value = value.to_s + " \u20BC" if options[:sign] && !(value.is_a? String)
return value
end
|