Class: NumbersAndWords::Translations::PtBr

Inherits:
Base
  • Object
show all
Includes:
Extensions::FractionSignificance, Families::Base
Defined in:
lib/numbers_and_words/translations/pt-BR.rb

Constant Summary

Constants inherited from Base

Base::I18N_NAMESPACE

Instance Method Summary collapse

Methods included from Extensions::FractionSignificance

#micro

Methods included from Families::Base

#mega, #micro_separator, #union

Methods inherited from Base

#t

Instance Method Details

#hundreds(number, options = {}) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 40

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



9
10
11
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 9

def integral(number, _options = {})
  t(:integral, count: number)
end

#megs(capacity, options = {}) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 49

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



63
64
65
66
67
68
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 63

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



57
58
59
60
61
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 57

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



17
18
19
20
21
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 17

def ones(number, options = {})
  return if options[:is_one_thousand]

  t([options[:prefix], :ones, options[:gender]].join('.'))[number]
end

#teens(number, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 29

def teens(number, options = {})
  return [tens(1, options), ones(number[0], options)].join(' ') if ordinal? options

  super(number, options)
end

#tens(number, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 23

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



35
36
37
38
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 35

def tens_with_ones(numbers, options = {})
  connector = ordinal?(options) ? ' ' : " #{union} "
  [tens(numbers[1], options), ones(numbers[0], options)].join(connector)
end

#zero(options = {}) ⇒ Object



13
14
15
# File 'lib/numbers_and_words/translations/pt-BR.rb', line 13

def zero(options = {})
  t([options[:prefix], :ones, :male].join('.'))[0]
end