Class: MCFDI::Address

Inherits:
Base
  • Object
show all
Defined in:
lib/m_cfdi/address.rb

Overview

Address Class for transmitter and receptor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attr_accessor, attributes, #attributes, #to_h

Constructor Details

#initialize(args = {}) ⇒ Address

Returns a new instance of Address.



19
20
21
# File 'lib/m_cfdi/address.rb', line 19

def initialize(args = {})
  args.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def city
  @city
end

#countryObject

Returns the value of attribute country.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def country
  @country
end

#interior_numberObject

Returns the value of attribute interior_number.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def interior_number
  @interior_number
end

#locationObject

Returns the value of attribute location.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def location
  @location
end

#neighborhoodObject

Returns the value of attribute neighborhood.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def neighborhood
  @neighborhood
end

#referenceObject

Returns the value of attribute reference.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def reference
  @reference
end

#stateObject

Returns the value of attribute state.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def state
  @state
end

#streetObject

Returns the value of attribute street.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def street
  @street
end

#street_numberObject

Returns the value of attribute street_number.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def street_number
  @street_number
end

#zip_codeObject

Returns the value of attribute zip_code.



16
17
18
# File 'lib/m_cfdi/address.rb', line 16

def zip_code
  @zip_code
end

Instance Method Details

#original_stringObject

return original string (cadena original) of the address.



24
25
26
27
28
29
30
31
32
# File 'lib/m_cfdi/address.rb', line 24

def original_string
  c = []
  self.attributes.each do |k|
    v = send(k)
    next unless v.present?
    c << v
  end
  c
end

#to_xObject

return hash with values in spanish for the xml.



35
36
37
38
39
40
# File 'lib/m_cfdi/address.rb', line 35

def to_x
  { calle: @street, noExterior: @street_number,
    noInterior: @interior_number, colonia: @neighborhood,
    localidad: @location, referencia: @reference, municipio: @city,
    estado: @state, pais: @country, codigoPostal: @zip_code }
end