kslazarev/numbers_and_words

View on GitHub
lib/numbers_and_words/strategies/figures_converter.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

require 'numbers_and_words/strategies/figures_converter/languages'
require 'numbers_and_words/strategies/figures_converter/options'
require 'numbers_and_words/strategies/figures_converter/decorators'

module NumbersAndWords
  module Strategies
    module FiguresConverter
      class Base
        attr_accessor :options, :figures, :translations, :language, :decorator

        def initialize(figures, options = {})
          @figures = figures.reverse

          @decorator = Decorators.factory(self, options)
          @options = Options::Proxy.new(self, options)
          @translations = Translations.factory
          @language = Languages.factory(self)
        end

        def run
          around { language.words }
        end

        private

        def around(&block)
          decorator.run(&block)
        end
      end
    end
  end
end