Class: CorreiosSigep::Models::LogisticReverse

Inherits:
Object
  • Object
show all
Includes:
DSL::LogisticReverse
Defined in:
lib/correios_sigep/models/logistic_reverse.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL::LogisticReverse

#with_collect, #with_recipient

Constructor Details

#initialize(options = {}) ⇒ LogisticReverse

Returns a new instance of LogisticReverse.



14
15
16
17
# File 'lib/correios_sigep/models/logistic_reverse.rb', line 14

def initialize(options = {})
  @collect    = options[:collect] || Models::Collect.new
  @recipient  = options[:recipient] || Models::Recipient.new
end

Instance Attribute Details

#collectObject

Returns the value of attribute collect.



6
7
8
# File 'lib/correios_sigep/models/logistic_reverse.rb', line 6

def collect
  @collect
end

#recipientObject

Returns the value of attribute recipient.



6
7
8
# File 'lib/correios_sigep/models/logistic_reverse.rb', line 6

def recipient
  @recipient
end

Class Method Details

.build(&block) ⇒ Object



8
9
10
11
12
# File 'lib/correios_sigep/models/logistic_reverse.rb', line 8

def self.build(&block)
  instance = new
  instance.instance_eval(&block)
  instance
end

Instance Method Details

#to_xmlObject



19
20
21
22
23
24
25
26
27
# File 'lib/correios_sigep/models/logistic_reverse.rb', line 19

def to_xml
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.root do
      Builders::XML::Recipient.new(xml, recipient).build_xml
      Builders::XML::Collect.new(xml, collect).build_xml
    end
  end
  builder.to_xml
end