Class: FE::Document::PhoneType

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

Direct Known Subclasses

Fax, Phone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, country_code, number) ⇒ PhoneType

Returns a new instance of PhoneType.



17
18
19
20
21
# File 'lib/facturacr/document/phone_type.rb', line 17

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.



10
11
12
# File 'lib/facturacr/document/phone_type.rb', line 10

def country_code
  @country_code
end

#numberObject

Returns the value of attribute number.



10
11
12
# File 'lib/facturacr/document/phone_type.rb', line 10

def number
  @number
end

#tag_nameObject

Returns the value of attribute tag_name.



10
11
12
# File 'lib/facturacr/document/phone_type.rb', line 10

def tag_name
  @tag_name
end

Instance Method Details

#build_xml(node) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/facturacr/document/phone_type.rb', line 23

def build_xml(node)
  raise "Invalid Record: #{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) ⇒ Object



32
33
34
# File 'lib/facturacr/document/phone_type.rb', line 32

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