Class: Error
- Inherits:
-
Object
- Object
- Error
- Defined in:
- lib/latchsdk/Error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(json) ⇒ Error
constructor
A new instance of Error.
-
#to_json ⇒ Object
JSON representing the Error Object.
Constructor Details
#initialize(json) ⇒ Error
Returns a new instance of Error.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/latchsdk/Error.rb', line 27 def initialize(json) if (json.is_a?(String)) json = JSON.Parse(json) end if(json.has_key?("code") && json.has_key?("message")) @code = json["code"] = json["message"] else puts "Error creating error object from string " + json end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
23 24 25 |
# File 'lib/latchsdk/Error.rb', line 23 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
24 25 26 |
# File 'lib/latchsdk/Error.rb', line 24 def end |
Instance Method Details
#to_json ⇒ Object
JSON representing the Error Object
41 42 43 44 45 46 |
# File 'lib/latchsdk/Error.rb', line 41 def to_json error = {} error["code"] = @code error["message"] = error.to_json end |