Class: ValidatorIE::StateAL
- Inherits:
-
Object
- Object
- ValidatorIE::StateAL
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/validator_ie/core/state_al.rb
Constant Summary collapse
- TYPE =
0-Normal, 3-Produtor Rural, 5-Substituta, 7- Micro-Empresa Ambulante, 8-Micro-Empresa
[0, 3, 5, 7, 8]
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ StateAL
constructor
A new instance of StateAL.
- #number_should_code_state ⇒ Object
- #number_should_mod11 ⇒ Object
- #number_should_type_factory ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ StateAL
Returns a new instance of StateAL.
15 16 17 18 19 |
# File 'lib/validator_ie/core/state_al.rb', line 15 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.
9 10 11 |
# File 'lib/validator_ie/core/state_al.rb', line 9 def number @number end |
Instance Method Details
#number_should_code_state ⇒ Object
21 22 23 |
# File 'lib/validator_ie/core/state_al.rb', line 21 def number_should_code_state number[0..1].eql?('24') end |
#number_should_mod11 ⇒ Object
29 30 31 32 33 |
# File 'lib/validator_ie/core/state_al.rb', line 29 def number_should_mod11 result = number_should_modX(11, number.size - 2) return if result errors.add(:number, 'não é válido para inscrição estadual.') end |
#number_should_type_factory ⇒ Object
25 26 27 |
# File 'lib/validator_ie/core/state_al.rb', line 25 def number_should_type_factory TYPE.include? number[2].to_i end |