class Egn::Parser
Attributes
date[R]
sex[R]
Public Class Methods
new(egn)
click to toggle source
Parses the given EGN and returns all information that can be extracted from it: date, sex and region
# File lib/egn/parser.rb, line 7 def initialize(egn) raise ArgumentError, 'Invalid EGN' unless Validator.validate(egn) # Extract the correct date year, month, day = egn.scan(/.{1,2}/).map(&:to_i) year, month = Util.determine_date(year, month) @date = Date.new(year.to_i, month, day) end