Skip to content
This repository
tree: dce1f0739b
Fetching contributors…

Cannot retrieve contributors at this time

file 21 lines (18 sloc) 0.588 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Real world scripts would use:
# require 'rubygems'
# require 'personnummer'
#
# Instead of:
require './lib/personnummer'

# Valid personnummer
p = Personnummer.new(8304285912)
designation = (p.male?) ? 'His' : 'Her'
puts "#{designation} control digit is: #{p.control_digit}"

if p.valid?
  designation = (p.male?) ? 'He' : 'She'
  puts "#{designation} was born in #{p.region} aproximately #{p.age} years ago" if p.region
end

# Incomplete personnummer
p = Personnummer.new('870312-594')
designation = (p.male?) ? 'His' : 'Her'
puts "#{designation} control digit is: #{p.control_digit}"
Something went wrong with that request. Please try again.