Class: FE::Document::PhoneType

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

Direct Known Subclasses

Fax, Phone

Instance Attribute Summary collapse

Attributes inherited from Element

#document, #version

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, country_code, number) ⇒ PhoneType

Returns a new instance of PhoneType.



13
14
15
16
17
# File 'lib/facturacr/document/phone_type.rb', line 13

def initialize(tag_name, country_code, number)
  @tag_name = tag_name
  @country_code = country_code
  @number = number
end

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code.



6
7
8
# File 'lib/facturacr/document/phone_type.rb', line 6

def country_code
  @country_code
end

#numberObject

Returns the value of attribute number.



6
7
8
# File 'lib/facturacr/document/phone_type.rb', line 6

def number
  @number
end

#tag_nameObject

Returns the value of attribute tag_name.



6
7
8
# File 'lib/facturacr/document/phone_type.rb', line 6

def tag_name
  @tag_name
end

Instance Method Details

#build_xml(node, document) ⇒ Object

Raises:



19
20
21
22
23
24
25
26
27
# File 'lib/facturacr/document/phone_type.rb', line 19

def build_xml(node, document)
  raise FE::Error.new("phone type invalid",class: self.class, messages: errors.messages) unless valid?
  
  node = Nokogiri::XML::Builder.new if node.nil?         
  node.send(tag_name) do |xml|
    xml.CodigoPais country_code
    xml.NumTelefono number
  end
end

#to_xml(builder, document) ⇒ Object



29
30
31
# File 'lib/facturacr/document/phone_type.rb', line 29

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