class NumbersAndWords::Translations::PtBr

Public Instance Methods

hundreds(number, options = {}) click to toggle source
# 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 = {}) click to toggle source
# File lib/numbers_and_words/translations/pt-BR.rb, line 9
def integral(number, _options = {})
  t(:integral, count: number)
end
megs(capacity, options = {}) click to toggle source
# 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 if options[:is_opaque] || options[:is_without_connector]

  suffix = options[:is_with_comma] ? ',' : " #{union}"
  super + suffix
end
micro_prefix(capacity, number) click to toggle source
# 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) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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
end
tens(number, options = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# File lib/numbers_and_words/translations/pt-BR.rb, line 13
def zero(options = {})
  t([options[:prefix], :ones, :male].join('.'))[0]
end

Private Instance Methods

ordinal?(options) click to toggle source
# File lib/numbers_and_words/translations/pt-BR.rb, line 72
def ordinal?(options)
  options[:prefix] == :ordinal
end