Class: PisPasepValidator::PisPasep
- Inherits:
-
Object
- Object
- PisPasepValidator::PisPasep
- Defined in:
- lib/pis_pasep_validator/pis_pasep.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
- #digit_verificator ⇒ Object
- #digits ⇒ Object
-
#initialize(number) ⇒ PisPasep
constructor
A new instance of PisPasep.
- #plain ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(number) ⇒ PisPasep
Returns a new instance of PisPasep.
8 9 10 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 8 def initialize(number) @number = number.to_s end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 6 def number @number end |
Class Method Details
.valid?(number) ⇒ Boolean
2 3 4 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 2 def self.valid?(number) new(number).valid? end |
Instance Method Details
#digit_verificator ⇒ Object
20 21 22 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 20 def digit_verificator digits[-1] end |
#digits ⇒ Object
12 13 14 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 12 def digits @digits ||= number.scan(/\d/).map(&:to_i) end |
#plain ⇒ Object
16 17 18 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 16 def plain @plain ||= digits.join end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/pis_pasep_validator/pis_pasep.rb', line 24 def valid? formatted? && !black_listed? && digits_matches? end |