Class: Opencellid::Error
- Inherits:
-
Object
- Object
- Opencellid::Error
- Defined in:
- lib/opencellid/error.rb
Overview
Models an error object received from the server
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#info ⇒ Object
Returns the value of attribute info.
Class Method Summary collapse
-
.from_element(element) ⇒ Error
Parses the given XML element extracting the information into the corresponding Error object.
Instance Method Summary collapse
-
#initialize(code, info) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(code, info) ⇒ Error
Returns a new instance of Error.
13 14 15 16 |
# File 'lib/opencellid/error.rb', line 13 def initialize(code, info) @info = info @code = code end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
9 10 11 |
# File 'lib/opencellid/error.rb', line 9 def code @code end |
#info ⇒ Object
Returns the value of attribute info.
9 10 11 |
# File 'lib/opencellid/error.rb', line 9 def info @info end |
Class Method Details
.from_element(element) ⇒ Error
Parses the given XML element extracting the information into the corresponding Error object
21 22 23 24 25 26 27 |
# File 'lib/opencellid/error.rb', line 21 def self.from_element(element) return nil unless element raise ArgumentError, 'element must be of type XEXML::Element' unless element.is_a? REXML::Element raise ArgumentError, 'element must be an <err>' unless element.name == 'err' attrs = element.attributes return Error.new(::Opencellid.to_i_or_nil(attrs['code']),attrs['info']) end |