Class: CommonNumbers::Polish::Regon

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

Instance Method Summary collapse

Constructor Details

#initialize(num) ⇒ Regon

Returns a new instance of Regon.



7
8
9
10
11
12
13
14
15
16
# File 'lib/common_numbers/regon.rb', line 7

def initialize(num)
  @factory = if(/^\d{9}$/ =~ num)
                Regon9.new num
             elsif(/^\d{14}$/ =~ num)
                Regon14.new num
             else
               nil
             end

end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/common_numbers/regon.rb', line 18

def valid?
  return @factory.valid? if @factory
  false
end