Class: ElfproefPlan::ElfProef
- Inherits:
-
Object
- Object
- ElfproefPlan::ElfProef
- Defined in:
- lib/elfproef_plan.rb
Instance Attribute Summary collapse
-
#letter ⇒ Object
Returns the value of attribute letter.
-
#nr ⇒ Object
Returns the value of attribute nr.
-
#nrs ⇒ Object
Returns the value of attribute nrs.
-
#subnr ⇒ Object
Returns the value of attribute subnr.
Instance Method Summary collapse
-
#initialize(input) ⇒ ElfProef
constructor
A new instance of ElfProef.
- #validBsn ⇒ Object
- #validLoonheffingennummer ⇒ Object
- #validRekening ⇒ Object
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
#letter ⇒ Object
Returns the value of attribute letter.
25 26 27 |
# File 'lib/elfproef_plan.rb', line 25 def letter @letter end |
#nr ⇒ Object
Returns the value of attribute nr.
25 26 27 |
# File 'lib/elfproef_plan.rb', line 25 def nr @nr end |
#nrs ⇒ Object
Returns the value of attribute nrs.
25 26 27 |
# File 'lib/elfproef_plan.rb', line 25 def nrs @nrs end |
#subnr ⇒ Object
Returns the value of attribute subnr.
25 26 27 |
# File 'lib/elfproef_plan.rb', line 25 def subnr @subnr end |
Instance Method Details
#validBsn ⇒ Object
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 |
#validLoonheffingennummer ⇒ Object
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 |
#validRekening ⇒ Object
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 |