Class: XeroGateway::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_gateway/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_timeObject

Returns the value of attribute date_time.



3
4
5
# File 'lib/xero_gateway/error.rb', line 3

def date_time
  @date_time
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/xero_gateway/error.rb', line 3

def description
  @description
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/xero_gateway/error.rb', line 3

def message
  @message
end

#typeObject

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")
  message = 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 => (message.text if message)
  )
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