<commit_before>require "russianpost/barcode_validator"

module RussianPost
  class Barcode
    extend Forwardable
    
    def_delegator :barcode, :=~

    attr_reader :barcode

    def initialize(barcode)
      @barcode = barcode.strip.upcase
      raise InvalidBarcode unless valid?
    end

    def to_s
      barcode
    end

    def digits
      barcode[/\d+/].split("").map(&:to_i)
    end

    private

    def valid?
      BarcodeValidator.validate(self)
    end
  end

  class InvalidBarcode < ArgumentError; end
end
<commit_msg>Reduced method complexity according to Flog<commit_after>require "russianpost/barcode_validator"

module RussianPost
  class Barcode
    extend Forwardable

    def_delegator :barcode, :=~

    attr_reader :barcode

    def initialize(barcode)
      @barcode = barcode.strip.upcase
      raise InvalidBarcode unless valid?
    end

    def to_s
      barcode
    end

    def digits
      barcode[/\d+/].split("").map { |d| d.to_i }
    end

    private

    def valid?
      BarcodeValidator.validate(self)
    end
  end

  class InvalidBarcode < ArgumentError; end
end

{'fraction_non_alphanumeric': 0.07484220018034266, 'fraction_numerical': 0.0, 'mean_word_length': 2.639344262295082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4090723', 'n_tokens_mistral': 363, 'n_tokens_neox': 355, 'n_words': 87}