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 8 9 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 5 def initialize number @number = clear_number(number).rjust number_length, '0' raise ArgumentError.new "invalid number" if @number.length != number_length end |
Instance Method Details
#number_length ⇒ Object
3 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 3 def number_length; 12; end |
#origin ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 28 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
12 13 14 15 16 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 12 def sequential @sequential ||= begin @number[/^(.*)....$/, 1] end end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 24 def to_s @number.scan(/\d{4}/).join ' ' end |
#uf_digit ⇒ Object
18 19 20 21 22 |
# File 'lib/brid/ids/titulo_eleitor.rb', line 18 def uf_digit @uf_digit ||= begin @number[/(..)..$/, 1] end end |