Class: Brid::TituloEleitor
- Defined in:
- lib/brid/ids/titulo_eleitor.rb
Instance Method Summary collapse
-
#initialize(number) ⇒ TituloEleitor
constructor
A new instance of TituloEleitor.
- #number_length ⇒ Object
- #origin ⇒ Object
- #sequential ⇒ Object
- #to_s ⇒ Object
- #uf_digit ⇒ Object
Methods inherited from GenericID
#check_digits, #check_digits_length, #invalid_sequential?, #valid?
Constructor Details
#initialize(number) ⇒ TituloEleitor
Returns a new instance of TituloEleitor.
5 6 7 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 5 def initialize number @number = clear_number(number) end |
Instance Method Details
#number_length ⇒ Object
3 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 3 def number_length; 10; end |
#origin ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 25 def origin @origin ||= begin [ nil, :sp, :mg, :rj, :rs, :ba, :pr, :ce, :pe, :sc, :go, :ma, :pb, :pa, :es, :pi, :rn, :al, :mt, :ms, :df, :se, :am, :ro, :ac, :ap, :rr, :to, :exterior ][uf_digit.to_i] end end |
#sequential ⇒ Object
9 10 11 12 13 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 9 def sequential @sequential ||= begin @number[/^(.*)....$/, 1] end end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 21 def to_s @number.scan(/\d{4}/).join ' ' end |
#uf_digit ⇒ Object
15 16 17 18 19 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 15 def uf_digit @uf_digit ||= begin @number[/(..)..$/, 1] end end |