lib/egn/util.rb in egn-1.3.3 vs lib/egn/util.rb in egn-1.3.4

- old
+ new

@@ -5,12 +5,12 @@ # The EGN can have three different formats depending on the century. It can # be determined by examining the month. # The rules are as follows: # * For people born in 1900..1999 the month does not change - # * For people born in 1800..1899 the month increases by 20 (e.g January is 21) - # * For people born in 2000..2099 the month increases by 40 (e.g December is 52) + # * For people born in 1800..1899 the month is increased by 20 (e.g January is 21) + # * For people born in 2000..2099 the month is increased by 40 (e.g December is 52) def self.determine_date(year, month) case month when (1..12) year = "19#{year}" when (21..32) @@ -22,10 +22,10 @@ end [year.to_i, month] end - # More information on the formula: http://www.grao.bg/esgraon.html + # More information on the formula: http://www.grao.bg/esgraon.html#section2 def self.egn_checksum(egn) sum = egn.chars.map(&:to_i).zip(WEIGHTS).map { |n| n.reduce(:*) }.reduce(:+) rest = sum % 11 rest < 10 ? rest : 0