module FFaker::IdentificationEC

def ci

Cedula de Identificacion
https://medium.com/@bryansuarez/c%C3%B3mo-validar-c%C3%A9dula-y-ruc-en-ecuador-b62c5666186f
def ci
  first_digits = ci_digits
  "#{first_digits}#{last_digit(first_digits)}"
end

def ci_digits

def ci_digits
  "#{FFaker.numerify('##')}#{rand(0..5)}#{FFaker.numerify('######')}"
end

def digits_sum(digits)

def digits_sum(digits)
  sum = 0
  digits.chars.each_with_index do |char, index|
    if index.even?
      multiple = char.to_i * 2
      sum += multiple > 9 ? multiple - 9 : multiple
    else
      sum += char.to_i
    end
  end
  sum
end

def last_digit(digits)

def last_digit(digits)
  mod = digits_sum(digits) % 10
  10 - mod if mod.positive?
end