Class: FE::Document::Location

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/facturacr/document/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Location

Returns a new instance of Location.



20
21
22
23
24
25
26
27
28
29
# File 'lib/facturacr/document/location.rb', line 20

def initialize(args={})
  
  @province = args[:province]
  @county = args[:county]
  @district = args[:district]
  @neighborhood = args[:neighborhood]
  @others = args[:others]
  
  
end

Instance Attribute Details

#countyObject

Returns the value of attribute county.



12
13
14
# File 'lib/facturacr/document/location.rb', line 12

def county
  @county
end

#districtObject

Returns the value of attribute district.



12
13
14
# File 'lib/facturacr/document/location.rb', line 12

def district
  @district
end

#neighborhoodObject

Returns the value of attribute neighborhood.



12
13
14
# File 'lib/facturacr/document/location.rb', line 12

def neighborhood
  @neighborhood
end

#othersObject

Returns the value of attribute others.



12
13
14
# File 'lib/facturacr/document/location.rb', line 12

def others
  @others
end

#provinceObject

Returns the value of attribute province.



12
13
14
# File 'lib/facturacr/document/location.rb', line 12

def province
  @province
end

Instance Method Details

#build_xml(node) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/facturacr/document/location.rb', line 31

def build_xml(node)
  raise "Location invalid: #{errors.messages}" unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?         
  node.Ubicacion do |x|
    x.Provincia @province
    x.Canton @county
    x.Distrito @district
    x.Barrio @neighborhood unless @neighborhood.nil?
    x.OtrasSenas @others
  end
end

#to_xml(builder) ⇒ Object



43
44
45
# File 'lib/facturacr/document/location.rb', line 43

def to_xml(builder)
  build_xml(builder).to_xml
end