Class: XeroGateway::Error
- Inherits:
-
Object
- Object
- XeroGateway::Error
- Defined in:
- lib/xero_gateway/error.rb
Instance Attribute Summary collapse
-
#date_time ⇒ Object
Returns the value of attribute date_time.
-
#description ⇒ Object
Returns the value of attribute description.
-
#message ⇒ Object
Returns the value of attribute message.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.parse(error_element) ⇒ Object
pass a REXML::Element error object to have returned a new Error object.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(params = {}) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(params = {}) ⇒ Error
Returns a new instance of Error.
5 6 7 8 9 |
# File 'lib/xero_gateway/error.rb', line 5 def initialize(params = {}) params.each do |k,v| self.send("#{k}=", v) end end |
Instance Attribute Details
#date_time ⇒ Object
Returns the value of attribute date_time.
3 4 5 |
# File 'lib/xero_gateway/error.rb', line 3 def date_time @date_time end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/xero_gateway/error.rb', line 3 def description @description end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/xero_gateway/error.rb', line 3 def @message end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/xero_gateway/error.rb', line 3 def type @type end |
Class Method Details
.parse(error_element) ⇒ Object
pass a REXML::Element error object to have returned a new Error object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xero_gateway/error.rb', line 20 def self.parse(error_element) description = REXML::XPath.first(error_element, "Description") date = REXML::XPath.first(error_element, "//DateTime") type = REXML::XPath.first(error_element, "//ExceptionType") = REXML::XPath.first(error_element, "//Message") Error.new( :description => (description.text if description), :date_time => (date.text if date), :type => (type.text if type), :message => (.text if ) ) end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/xero_gateway/error.rb', line 11 def ==(other) [:description, :date_time, :type, :message].each do |field| return false if send(field) != other.send(field) end return true end |