Class: Brid::TituloEleitor
- Defined in:
- lib/brid/ids/titulo_eleitor.rb
Instance Attribute Summary
Attributes inherited from GenericID
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, #freeze, #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).rjust number_length, '0' end |
Instance Method Details
#number_length ⇒ Object
3 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 3 def number_length; 12; end |
#origin ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 26 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
10 11 12 13 14 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 10 def sequential @sequential ||= begin @number[/^(.*)....$/, 1] end end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 22 def to_s @number.scan(/\d{4}/).join ' ' end |
#uf_digit ⇒ Object
16 17 18 19 20 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 16 def uf_digit @uf_digit ||= begin @number[/(..)..$/, 1] end end |