Class: ElfproefPlan::ElfProef

Inherits:
Object
  • Object
show all
Defined in:
lib/elfproef_plan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ ElfProef

Returns a new instance of ElfProef.



27
28
29
30
31
32
33
# File 'lib/elfproef_plan.rb', line 27

def initialize(input)
	@nrs = (2..9).to_a.reverse
    
    		@nr, @letter, @subnr = input.to_s.scan(/[0-9a-zA-Z+$]/).join().upcase().match(/([0-9]*)([A-Z]*)([0-9]*)/i).captures.map{|x| x.scan(/./)}
    		@nr, @subnr = @nr.map{|x| x.to_i}, @subnr.map{|x| x.to_i}

end

Instance Attribute Details

#letterObject

Returns the value of attribute letter.



25
26
27
# File 'lib/elfproef_plan.rb', line 25

def letter
  @letter
end

#nrObject

Returns the value of attribute nr.



25
26
27
# File 'lib/elfproef_plan.rb', line 25

def nr
  @nr
end

#nrsObject

Returns the value of attribute nrs.



25
26
27
# File 'lib/elfproef_plan.rb', line 25

def nrs
  @nrs
end

#subnrObject

Returns the value of attribute subnr.



25
26
27
# File 'lib/elfproef_plan.rb', line 25

def subnr
  @subnr
end

Instance Method Details

#validBsnObject



41
42
43
44
45
46
# File 'lib/elfproef_plan.rb', line 41

def validBsn
	return false if @nr.length > 9
	@nr.unshift 0 while @nr.length < 9
	return false if @nr[0,3].sum < 1
	elfproef(-1)
end

#validLoonheffingennummerObject



48
49
50
51
52
53
54
# File 'lib/elfproef_plan.rb', line 48

def validLoonheffingennummer
	return false unless validBsn
	return false unless @letter==["L"]
	return false unless @subnr.reduce(:+)>0
	true

end

#validRekeningObject



35
36
37
38
39
# File 'lib/elfproef_plan.rb', line 35

def validRekening
	return false unless [9, 10].include? @nr.length
	@nrs.unshift 10 if @nr.length == 10
	elfproef(1)
end