Sha256: 66ee52a1b7b44beb660dd0ae8a711c6ba302a40badc57719e41cfb9944f367c8

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

module ItaxCode
  ##
  # This class holds the TaxCode validation logic.
  #
  # @param [Hash] data The citizen input data

  class Validator
    LENGTH = 16

    def initialize(data = {})
      @encoded = Encoder.new(data).encode
    end

    class << self
      ##
      # This method checks tax code standard length
      # against citizen and business fical code standards.
      #
      # @param [String] code The tax code
      #
      # @return [true, false]

      def standard_length?(code)
        code.length == LENGTH
      end
    end

    ##
    # This method check pre calculated tax code validity
    # against newly encoded tax code.
    #
    # @param [String] tax_code The pre calculated tax code
    #
    # @return [true, false]

    def valid?(tax_code)
      encoded[0..10] == tax_code[0..10]
    end

    private

      attr_accessor :encoded
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itax_code-0.1.2 lib/itax_code/validator.rb