require "jan/version"
require "jan/parser"
require "jan/check_digit_calculator"
require "jan/validator"
require "jan/random"

class Jan < ::String
  InstorePrefixes = %w(02 20 21 22 23 24 25 26 27 28 29)

  attr_accessor :code

  def initialize(code)
    @code = code
    super(code.to_s)
  end

  def valid?
    Validator.validate(@code)
  end

  def check_digit
    Parser.check_digit(@code)
  end

  def even_digits
    Parser.even_digits(@code)
  end

  def odd_digits
    Parser.odd_digits(@code)
  end

  def instore_code?
    Parser.instore_code?(@code)
  end
end

require "jan/check_digit_calculator"
require "jan/parser"
require "jan/random"
require "jan/validator"
require "jan/version"

class Jan < ::String
  InstorePrefixes = %w(02 20 21 22 23 24 25 26 27 28 29)

  def initialize(code)
    super(code.to_s)
  end

  def valid?
    Validator.validate(self)
  end

  def check_digit
    Parser.check_digit(self)
  end

  def even_digits
    Parser.even_digits(self)
  end

  def odd_digits
    Parser.odd_digits(self)
  end

  def instore_code?
    Parser.instore_code?(self)
  end
end

Remove instance variable @code form Jan.
Remove instance variable @code form Jan.
