Sha256: 3ce79cd2facc3d0f963fb300fe7c6bfe045a11ab58910d48e67880c7026ff6b1

Contents?: true

Size: 473 Bytes

Versions: 9

Compression:

Stored size: 473 Bytes

Contents

module Egn
  class Parser
    attr_reader :date, :sex

    # Parses the given EGN and returns all information that can be
    # extracted from it: date, sex and region
    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

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
egn-1.3.2 lib/egn/parser.rb
egn-1.3.1 lib/egn/parser.rb
egn-1.3.0 lib/egn/parser.rb
egn-1.2.2 lib/egn/parser.rb
egn-1.2.1 lib/egn/parser.rb
egn-1.2.0 lib/egn/parser.rb
egn-1.1.0 lib/egn/parser.rb
egn-1.0.0 lib/egn/parser.rb
egn-0.4.0 lib/egn/parser.rb