Class: NumbersAndWords::Translations::PtBr
Constant Summary
Constants inherited
from Base
Base::I18N_NAMESPACE
Instance Method Summary
collapse
#micro
#mega, #micro_separator, #union
Methods inherited from Base
#t
Instance Method Details
#hundreds(number, options = {}) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 36
def hundreds(number, options = {})
return t(:one_hundred) if options[:is_one_hundred] && !ordinal?(options)
hundreds = t([options[:prefix], :hundreds, options[:gender]].join('.'))[number]
return hundreds if ordinal?(options) || options[:is_hundred]
[hundreds, union].join(' ')
end
|
#integral(number, _options = {}) ⇒ Object
7
8
9
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 7
def integral(number, _options = {})
t(:integral, count: number)
end
|
#megs(capacity, options = {}) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 43
def megs(capacity, options = {})
return t([options[:prefix], :mega, options[:gender]].join('.'))[capacity] if ordinal?(options)
return super(capacity, options) if options[:is_opaque] || options[:is_without_connector]
suffix = options[:is_with_comma] ? ',' : " #{union}"
super(capacity, options) + suffix
end
|
#micro_prefix(capacity, number) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 56
def micro_prefix(capacity, number)
case capacity
when 2 then t('micro_prefix.hundreds', count: number)
when 1 then t('micro_prefix.tens', count: number)
end
end
|
#micros(capacity, number = nil) ⇒ Object
50
51
52
53
54
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 50
def micros(capacity, number = nil)
micro, prefix = capacity
micros = number ? t(micro(micro), count: number) : micro(micro)
[micro_prefix(prefix, number), micros].compact.join(t('micro_prefix.union'))
end
|
#ones(number, options = {}) ⇒ Object
15
16
17
18
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 15
def ones(number, options = {})
return if options[:is_one_thousand]
t([options[:prefix], :ones, options[:gender]].join('.'))[number]
end
|
#teens(number, options = {}) ⇒ Object
26
27
28
29
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 26
def teens(number, options = {})
return [tens(1, options), ' ', ones(number[0], options)].join if ordinal? options
super(number, options)
end
|
#tens(number, options = {}) ⇒ Object
20
21
22
23
24
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 20
def tens(number, options = {})
path = [options[:prefix], :tens]
path.push(options[:gender]) if ordinal?(options)
t(path.join('.'))[number]
end
|
#tens_with_ones(numbers, options = {}) ⇒ Object
31
32
33
34
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 31
def tens_with_ones(numbers, options = {})
connector = ordinal?(options) ? ' ' : " #{union} "
[tens(numbers[1], options), connector, ones(numbers[0], options)].join
end
|
#zero(options = {}) ⇒ Object
11
12
13
|
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 11
def zero(options = {})
t([options[:prefix], :ones, :male].join('.'))[0]
end
|