Class: FotoliaRest::Result
- Inherits:
-
Object
- Object
- FotoliaRest::Result
- Defined in:
- lib/fotolia_rest/result.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, body) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(code, body) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fotolia_rest/result.rb', line 7 def initialize(code, body) @response = JSON.parse(body) case code.to_s when "200" @success = true else @success = false @error = FotoliaApiError.new(@response['code'], @response['error']) end end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/fotolia_rest/result.rb', line 5 def error @error end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/fotolia_rest/result.rb', line 5 def response @response end |
Class Method Details
.parse(response) ⇒ Object
23 24 25 |
# File 'lib/fotolia_rest/result.rb', line 23 def parse(response) self.new(response.code, response.body) end |
Instance Method Details
#success? ⇒ Boolean
18 19 20 |
# File 'lib/fotolia_rest/result.rb', line 18 def success? @success end |