Class: Gentle::ErrorMessage
- Inherits:
-
Object
- Object
- Gentle::ErrorMessage
- Defined in:
- lib/gentle/error_message.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ErrorMessage
constructor
A new instance of ErrorMessage.
- #shipment_number ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ErrorMessage
Returns a new instance of ErrorMessage.
5 6 7 |
# File 'lib/gentle/error_message.rb', line 5 def initialize( = {}) @xml = Nokogiri::XML::Document.parse([:xml]) if [:xml] end |
Instance Attribute Details
#xml ⇒ Object (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_number ⇒ Object
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_xml ⇒ Object
9 10 11 |
# File 'lib/gentle/error_message.rb', line 9 def to_xml @xml.serialize(encoding: "UTF-8") end |