Class: RfcFacil::Rfc

Inherits:
Object
  • Object
show all
Defined in:
lib/rfc_facil/rfc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Rfc

Returns a new instance of Rfc.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rfc_facil/rfc.rb', line 6

def initialize(args)
  @name = args[:name]
  @first_last_name = args[:first_last_name]
  @second_last_name = args[:second_last_name]
  @day = args[:day]
  @month = args[:month]
  @year = args[:year]
  @legal_name = args[:legal_name]
  if @legal_name.nil?
    build_natural_person
  else
    build_juristic_person
  end
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def day
  @day
end

#first_last_nameObject

Returns the value of attribute first_last_name.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def first_last_name
  @first_last_name
end

#homoclaveObject

Returns the value of attribute homoclave.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def homoclave
  @homoclave
end

Returns the value of attribute legal_name.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def legal_name
  @legal_name
end

#monthObject

Returns the value of attribute month.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def month
  @month
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def name
  @name
end

#second_last_nameObject

Returns the value of attribute second_last_name.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def second_last_name
  @second_last_name
end

#ten_digits_codeObject

Returns the value of attribute ten_digits_code.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def ten_digits_code
  @ten_digits_code
end

#verification_digitObject

Returns the value of attribute verification_digit.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def verification_digit
  @verification_digit
end

#yearObject

Returns the value of attribute year.



3
4
5
# File 'lib/rfc_facil/rfc.rb', line 3

def year
  @year
end

Instance Method Details

#build_juristic_personObject



21
22
23
# File 'lib/rfc_facil/rfc.rb', line 21

def build_juristic_person

end

#build_natural_personObject



25
26
27
28
29
30
# File 'lib/rfc_facil/rfc.rb', line 25

def build_natural_person
  @person = NaturalPerson.new(@name, @first_last_name, @second_last_name, @day, @month, @year)
  @ten_digits_code = NaturalTenDigitsCodeCalculator.new(@person).calculate
  @homoclave = HomoclaveCalculator.new(@person).calculate
  @verification_digit = VerificationDigitCalculator.new("#{@ten_digits_code}#{@homoclave}").calculate
end

#to_sObject



32
33
34
# File 'lib/rfc_facil/rfc.rb', line 32

def to_s
  "#{@ten_digits_code}#{@homoclave}#{@verification_digit}"
end