module CurpGenerator::Helpers
Public Instance Methods
blank_string?(value)
click to toggle source
# File lib/helpers.rb, line 38 def blank_string?(value) value.to_s.strip.empty? end
parse_attribute(attribute)
click to toggle source
# File lib/helpers.rb, line 29 def parse_attribute(attribute) return if blank_string?(attribute) CurpGenerator::StringFormat.new(remove_composed_names(attribute)).str end
parse_date(date, format)
click to toggle source
# File lib/helpers.rb, line 34 def parse_date(date, format) date.strftime(format) end
remove_composed_names(name)
click to toggle source
# File lib/helpers.rb, line 19 def remove_composed_names(name) name = name.upcase COMPOSED_NAMES.each do |composed| next unless name.include?(composed) name = name.gsub(composed, '') end name end
verifying_digit(partial_curp)
click to toggle source
# File lib/helpers.rb, line 8 def verifying_digit(partial_curp) length_sum = 0.0 partial_curp.split('').each_with_index do |character, index| length_sum += VALID_CHARACTERS.index(character) * (18 - index) end last_digit = 10 - (length_sum % 10) last_digit == 10 ? '0' : last_digit.to_i.to_s end