Class: FlickrResponse
- Inherits:
-
Object
- Object
- FlickrResponse
- Defined in:
- lib/objectiveflickr/flickr_response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#[](x) ⇒ Object
A quick accessor to the data block.
-
#error? ⇒ Boolean
Returns true if there’s something wrong with the method call.
-
#error_code ⇒ Object
Returns Flickr’s error code, 0 if none.
-
#error_message ⇒ Object
Returns Flickr error message, nil if none.
-
#initialize(response) ⇒ FlickrResponse
constructor
Initializes the instance with reponse block data.
-
#ok? ⇒ Boolean
Returns true if it’s a valid Flickr response.
Constructor Details
#initialize(response) ⇒ FlickrResponse
Initializes the instance with reponse block data
24 25 26 |
# File 'lib/objectiveflickr/flickr_response.rb', line 24 def initialize(response) @data = JSON.parse(response) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/objectiveflickr/flickr_response.rb', line 21 def data @data end |
Instance Method Details
#[](x) ⇒ Object
A quick accessor to the data block
49 50 51 |
# File 'lib/objectiveflickr/flickr_response.rb', line 49 def [](x) @data[x] end |
#error? ⇒ Boolean
Returns true if there’s something wrong with the method call
34 35 36 |
# File 'lib/objectiveflickr/flickr_response.rb', line 34 def error? return !ok? end |
#error_code ⇒ Object
Returns Flickr’s error code, 0 if none
39 40 41 |
# File 'lib/objectiveflickr/flickr_response.rb', line 39 def error_code @data["code"] || 0 end |
#error_message ⇒ Object
Returns Flickr error message, nil if none
44 45 46 |
# File 'lib/objectiveflickr/flickr_response.rb', line 44 def @data["message"] end |
#ok? ⇒ Boolean
Returns true if it’s a valid Flickr response
29 30 31 |
# File 'lib/objectiveflickr/flickr_response.rb', line 29 def ok? return @data["stat"] == "ok" ? true : false end |