Class: ValidatorIE::StateTO
- Inherits:
-
Object
- Object
- ValidatorIE::StateTO
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/validator_ie/core/state_to.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ StateTO
constructor
A new instance of StateTO.
- #number_should_mod11 ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ StateTO
Returns a new instance of StateTO.
12 13 14 15 16 |
# File 'lib/validator_ie/core/state_to.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_to.rb', line 8 def number @number end |
Instance Method Details
#number_should_mod11 ⇒ Object
18 19 20 21 22 23 |
# File 'lib/validator_ie/core/state_to.rb', line 18 def number_should_mod11 self.number = number.split(//).map.with_index {|m, k| m unless k == 2 || k == 3}.compact!.join('') result = number_should_modX(11, 7) return if result errors.add(:number, 'não é válido para inscrição estadual.') end |