Class: Gentle::ErrorMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/gentle/error_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ErrorMessage

Returns a new instance of ErrorMessage.



5
6
7
# File 'lib/gentle/error_message.rb', line 5

def initialize(options = {})
  @xml = Nokogiri::XML::Document.parse(options[:xml]) if options[:xml]
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



3
4
5
# File 'lib/gentle/error_message.rb', line 3

def xml
  @xml
end

Instance Method Details

#shipment_numberObject



13
14
15
16
17
# File 'lib/gentle/error_message.rb', line 13

def shipment_number
  result_description = @xml.css("ErrorMessage").first["ResultDescription"]
  match_data = result_description.match(/(.+)_(.+)_(.+)_.*.xml/) unless result_description.nil?
  match_data[2] unless match_data.nil?
end

#to_xmlObject



9
10
11
# File 'lib/gentle/error_message.rb', line 9

def to_xml
  @xml.serialize(encoding: "UTF-8")
end