Class: IdNumberLatam::Base
- Inherits:
-
Object
- Object
- IdNumberLatam::Base
- Extended by:
- Forwardable
- Defined in:
- lib/id_number_latam/base.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#id_number ⇒ Object
Returns the value of attribute id_number.
-
#unformatted_id_number ⇒ Object
Returns the value of attribute unformatted_id_number.
Instance Method Summary collapse
- #get_dni_class ⇒ Object
-
#initialize(id_number, opts = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(id_number, opts = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 |
# File 'lib/id_number_latam/base.rb', line 12 def initialize(id_number, opts = {}) @id_number = id_number @country = opts.delete(:country)&.to_sym @dni_class = get_dni_class.new(@id_number) if @country end |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
10 11 12 |
# File 'lib/id_number_latam/base.rb', line 10 def country @country end |
#id_number ⇒ Object
Returns the value of attribute id_number.
10 11 12 |
# File 'lib/id_number_latam/base.rb', line 10 def id_number @id_number end |
#unformatted_id_number ⇒ Object
Returns the value of attribute unformatted_id_number.
10 11 12 |
# File 'lib/id_number_latam/base.rb', line 10 def unformatted_id_number @unformatted_id_number end |
Instance Method Details
#get_dni_class ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/id_number_latam/base.rb', line 18 def get_dni_class return unless @country country_dni_class = IdNumberLatam.constants.map(&:to_s).detect { |c| c == "#{@country.capitalize}Dni" } unless country_dni_class raise "class IdNumberLatam::#{@country.capitalize}Dni not implemented for #{@country} country code" end IdNumberLatam.const_get country_dni_class end |