Class: ValidatorIE::StateBA
- Inherits:
-
Object
- Object
- ValidatorIE::StateBA
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/validator_ie/core/state_ba.rb
Constant Summary collapse
- MOD10 =
[0,1,2,3,4,5,8]
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ StateBA
constructor
A new instance of StateBA.
- #number_should_mod ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ StateBA
Returns a new instance of StateBA.
12 13 14 15 16 |
# File 'lib/validator_ie/core/state_ba.rb', line 12 def initialize(opts={}) opts.each do |key, value| self.public_send("#{key}=", value) end end |
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
8 9 10 |
# File 'lib/validator_ie/core/state_ba.rb', line 8 def number @number end |
Instance Method Details
#number_should_mod ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/validator_ie/core/state_ba.rb', line 18 def number_should_mod if MOD10.include? number[0].to_i result = number_should_modX(10, number.size == 8 ? 5 : 6) else result = number_should_modX(11, number.size == 8 ? 5 : 6) end return if result errors.add(:number, 'não é válido para inscrição estadual.') end |