kslazarev/numbers_and_words

View on GitHub
lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module NumbersAndWords
  module Strategies
    module FiguresConverter
      module Options
        module En
          class HundredsWithUnion
            attr_accessor :strategy, :options

            def initialize(proxy, *_args)
              @strategy = proxy.strategy
              @options = proxy.options
            end

            def modify_or_leave(hundreds)
              hundreds = "#{hundreds} #{translations.union}" if active? && !round_hundred?
              hundreds
            end

            private

            def active?
              @options[:hundreds_with_union]
            end

            def round_hundred?
              @strategy.language.figures.round_hundred?
            end

            def translations
              @strategy.translations
            end
          end
        end
      end
    end
  end
end