Class: FE::Document::Receiver
- Inherits:
-
Object
- Object
- FE::Document::Receiver
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/facturacr/document/receiver.rb
Instance Attribute Summary collapse
-
#comercial_name ⇒ Object
Returns the value of attribute comercial_name.
-
#email ⇒ Object
Returns the value of attribute email.
-
#fax ⇒ Object
Returns the value of attribute fax.
-
#foreign_id_number ⇒ Object
Returns the value of attribute foreign_id_number.
-
#identification_document ⇒ Object
Returns the value of attribute identification_document.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
Instance Method Summary collapse
- #build_xml(node) ⇒ Object
-
#initialize(args = {}) ⇒ Receiver
constructor
A new instance of Receiver.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Receiver
Returns a new instance of Receiver.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/facturacr/document/receiver.rb', line 20 def initialize(args={}) @name = args[:name] @identification_document = args[:identification_document] @comercial_name = args[:comercial_name] @location = args[:location] @phone = args[:phone] @fax = args[:fax] @email = args[:email] @foreign_id_number = args[:foreign_id_number] end |
Instance Attribute Details
#comercial_name ⇒ Object
Returns the value of attribute comercial_name.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def comercial_name @comercial_name end |
#email ⇒ Object
Returns the value of attribute email.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def email @email end |
#fax ⇒ Object
Returns the value of attribute fax.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def fax @fax end |
#foreign_id_number ⇒ Object
Returns the value of attribute foreign_id_number.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def foreign_id_number @foreign_id_number end |
#identification_document ⇒ Object
Returns the value of attribute identification_document.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def identification_document @identification_document end |
#location ⇒ Object
Returns the value of attribute location.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
12 13 14 |
# File 'lib/facturacr/document/receiver.rb', line 12 def phone @phone end |
Instance Method Details
#build_xml(node) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/facturacr/document/receiver.rb', line 33 def build_xml(node) raise "IdentificationDocument is invalid" if !@identification_document.nil? && !@identification_document.is_a?(IdentificationDocument) raise "Location is invalid" if !@location.nil? && !@location.is_a?(Location) raise "Phone is invalid" if !@phone.nil? && !@phone.is_a?(Phone) raise "Fax is invalid" if !@fax.nil? && !@fax.is_a?(Fax) raise "Reciever is invalid: #{errors.}" unless valid? node = Nokogiri::XML::Builder.new if node.nil? node.Receptor do |xml| xml.Nombre @name @identification_document.build_xml(xml) if @identification_document.present? xml.IdentificacionExtranjer foreign_id_number if @foreign_id_number.present? xml.NombreComercial @comercial_name if @comercial_name.present? @location.build_xml(xml) if @location.present? @phone.build_xml(xml) if @phone.present? @fax.build_xml(xml) if @fax.present? xml.CorreElectronico @email if @email.present? end end |
#to_xml(builder) ⇒ Object
53 54 55 |
# File 'lib/facturacr/document/receiver.rb', line 53 def to_xml(builder) build_xml(builder).to_xml end |