Class: FE::Document::Regulation

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

Instance Attribute Summary collapse

Attributes inherited from Element

#document, #version

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Regulation

Returns a new instance of Regulation.



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

def initialize(args={})
  @number = args[:number] ||= "DGT-R-48-2016"
  @date = args[:date] ||= "20-02-2017 13:22:22"
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#numberObject

Returns the value of attribute number.



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

def number
  @number
end

Instance Method Details

#build_xml(node, document) ⇒ Object

Raises:



16
17
18
19
20
21
22
23
# File 'lib/facturacr/document/regulation.rb', line 16

def build_xml(node, document)
  raise FE::Error.new("regulation invalid",class: self.class, messages: errors.messages) unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?
  node.Normativa do |xml|
    xml.NumeroResolucion @number
    xml.FechaResolucion @date
  end
end