Class: RfcFacil::Rfc
- Inherits:
-
Object
- Object
- RfcFacil::Rfc
- Defined in:
- lib/rfc_facil/rfc.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#first_last_name ⇒ Object
Returns the value of attribute first_last_name.
-
#homoclave ⇒ Object
Returns the value of attribute homoclave.
-
#legal_name ⇒ Object
Returns the value of attribute legal_name.
-
#month ⇒ Object
Returns the value of attribute month.
-
#name ⇒ Object
Returns the value of attribute name.
-
#second_last_name ⇒ Object
Returns the value of attribute second_last_name.
-
#ten_digits_code ⇒ Object
Returns the value of attribute ten_digits_code.
-
#verification_digit ⇒ Object
Returns the value of attribute verification_digit.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #build_juristic_person ⇒ Object
- #build_natural_person ⇒ Object
-
#initialize(args) ⇒ Rfc
constructor
A new instance of Rfc.
- #to_s ⇒ Object
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
#day ⇒ Object
Returns the value of attribute day.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def day @day end |
#first_last_name ⇒ Object
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 |
#homoclave ⇒ Object
Returns the value of attribute homoclave.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def homoclave @homoclave end |
#legal_name ⇒ Object
Returns the value of attribute legal_name.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def legal_name @legal_name end |
#month ⇒ Object
Returns the value of attribute month.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def month @month end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def name @name end |
#second_last_name ⇒ Object
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_code ⇒ Object
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_digit ⇒ Object
Returns the value of attribute verification_digit.
3 4 5 |
# File 'lib/rfc_facil/rfc.rb', line 3 def verification_digit @verification_digit end |
#year ⇒ Object
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_person ⇒ Object
21 22 23 |
# File 'lib/rfc_facil/rfc.rb', line 21 def build_juristic_person end |
#build_natural_person ⇒ Object
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_s ⇒ Object
32 33 34 |
# File 'lib/rfc_facil/rfc.rb', line 32 def to_s "#{@ten_digits_code}#{@homoclave}#{@verification_digit}" end |